-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onnxruntime: add with_cuda option #22557
onnxruntime: add with_cuda option #22557
Conversation
This comment has been minimized.
This comment has been minimized.
👋
On 1.15.1 with CUDA enabled we did not have this error. Might be a compiler mismatch of sorts; we use Clang-11, which was released in 2021. Would be nice if someone could verify this; maybe CCI should have patch for it as well.
--- a/cmake/onnxruntime_providers.cmake
+++ b/cmake/onnxruntime_providers.cmake
@@ -479,7 +479,8 @@ if (onnxruntime_USE_CUDA)
target_compile_options(onnxruntime_providers_cuda PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:-Xcompiler /wd4127>")
endif()
- onnxruntime_add_include_to_target(onnxruntime_providers_cuda onnxruntime_common onnxruntime_framework onnx onnx_proto ${PROTOBUF_LIB} flatbuffers::flatbuffers)
+ onnxruntime_add_include_to_target(onnxruntime_providers_cuda onnxruntime_common onnxruntime_framework onnx_proto)
+ target_link_libraries(onnxruntime_providers_cuda PUBLIC onnx onnx_proto protobuf::protobuf flatbuffers::flatbuffers Eigen3::Eigen3)
if (onnxruntime_ENABLE_TRAINING_OPS)
onnxruntime_add_include_to_target(onnxruntime_providers_cuda onnxruntime_training)
if (onnxruntime_ENABLE_TRAINING)
--- a/onnxruntime/contrib_ops/cuda/bert/attention.cc
+++ b/onnxruntime/contrib_ops/cuda/bert/attention.cc
@@ -164,7 +164,6 @@ Status Attention<T>::ComputeInternal(OpKernelContext* context) const {
has_memory_efficient_attention(sm, sizeof(T) == 2);
#else
constexpr bool use_memory_efficient_attention = false;
- ORT_UNUSED_VARIABLE(is_mask_1d_key_seq_len_start);
#endif
cublasHandle_t cublas = GetCublasHandle(context); On Protobuf+Flatbuffers, I do not remember the exact errors, but I think their
def build_requirements(self):
# Required by upstream https://github.com/microsoft/onnxruntime/blob/v1.14.1/cmake/CMakeLists.txt#L5
self.tool_requires("cmake/[>=3.24 <4]")
self.tool_requires("ninja/1.11.1")
# CUDA: cannot make CUDA a conan package, have to rely on system pre-configured
if self.options.with_cuda and self.settings.os == 'Linux':
if not shutil.which("nvcc"):
self.output.error(
"Need CUDA toolkit! Here is how you can install it:\n"
" wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.1-1_all.deb\n"
" dpkg -i cuda-keyring_1.1-1_all.deb\n"
" apt update\n"
" apt install cuda-toolkit-11-8"
)
raise RuntimeError("nvcc not found; see logs")
from subprocess import check_output
output = check_output(["nvcc", "--version"]).decode()
if not "release 11" in output:
self.output.error(f"nvcc found but wrong version (11.8 recommended):\n\n{output}")
raise RuntimeError("invalid nvcc version; see logs")
if not self.options.shared:
rm(
conanfile=self,
pattern="*onnxruntime_providers_shared*",
folder=os.path.join(self.package_folder, "lib"),
) |
I forgot to mention that I only tested onnxruntime 1.14.1, I guess I should try with this other versions and implement you changes if I get the same errors with my compiler. To answer some of your questions:
https://onnxruntime.ai/docs/build/eps.html#loading-the-shared-providers, and the static build + shared providers is a well supported configuration so I think we should not add a limitation.
|
I updated the MR to be able to build 1.15.1 with cuda. However I cannot build the 1.16.x because I have only a cuda 11.4 configuration, which apparently is too old to work with VS2022 (required for 1.16.x). But maybe this first version is enough and further adjustments can be in another MR (they still can be built without cuda like before)? |
… into onnxruntime-with-cuda
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Conan v1 pipeline ✔️All green in build 6 (
Conan v2 pipeline ✔️
All green in build 6 (
|
* Add with_cuda option * Require static registration from onnx disabled * Add some transitive headers * Test CUDA in the test_package * Add 1.15.1 patch * wip * add comment * wip * wip * wip * remove unused patch * better patching * remove unused patch * fix * copy dlls via cmake in v1 * check if win --------- Co-authored-by: czoido <mrgalleta@gmail.com>
Fix #22555
I started from this PR which is currently stale: #20392 and added the following changes:
onnxruntime_DISABLE_CONTRIB_OPS
=> CONTRIB_OPS seems mandatory to build CUDA provider so leave it as beforeuse_cuda
bywith_cuda
with_cuda
option in the test_packageNote that according to onnxruntime documentation the main dll shall be next the to the modules: https://onnxruntime.ai/docs/build/eps.html#loading-the-shared-providers so for this specific recipe we shall move the dll in the bin dir.
Changes not directly related to cuda:
This was tested on Linux gcc11 and Windows msvc192 with and without the option.
Assuming you have a
cuda
package from the pre built libs provided by NVIDIA, this is the additional changes I had to do: