From 8568a676734c97790c9fbf918b5f3fc00e271e80 Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Tue, 16 Jul 2024 10:05:33 -0700 Subject: [PATCH] Fix a build error when CUDA is enabled and onnxruntime_DISABLE_CONTRIB_OPS is ON (#21285) Resolve #21204 To reproduce the issue, build the code with ``` python3 tools/ci_build/build.py --build_dir /tmp/build13 --config Debug --skip_submodule_sync --build_shared_lib --parallel --use_binskim_compliant_compile_flags --build_csharp --enable_onnx_tests --update --build --build_wheel --use_cuda --cuda_home /usr/local/cuda --cudnn_home /usr/local/cuda --cmake_extra_defines onnxruntime_DISABLE_CONTRIB_OPS=ON onnxruntime_BUILD_UNIT_TESTS=OFF --skip_tests ``` Then run the following python script: ```python #!/usr/bin/python3 import onnxruntime as ort providers = [("CUDAExecutionProvider")] ort_sess = ort.InferenceSession('/data/onnx/opset17/test_gemm_default_no_bias/model.onnx', providers=providers) ``` Without this fix, you will see an error: Failed to load library libonnxruntime_providers_cuda.so with error: /tmp/build18/Debug/onnxruntime/capi/libonnxruntime_providers_cuda.so: undefined symbol: _ZN11onnxruntime4cuda21BuildKernelCreateInfoINS0_57kCudaExecutionProvider_GridSample_kOnnxDomain_ver16_floatEEENS_16KernelCreateInfoEv --- .../cuda => core/providers/cuda/tensor}/grid_sample.cc | 0 .../cuda => core/providers/cuda/tensor}/grid_sample.h | 0 .../cuda => core/providers/cuda/tensor}/grid_sample_impl.cu | 0 .../cuda => core/providers/cuda/tensor}/grid_sample_impl.h | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename onnxruntime/{contrib_ops/cuda => core/providers/cuda/tensor}/grid_sample.cc (100%) rename onnxruntime/{contrib_ops/cuda => core/providers/cuda/tensor}/grid_sample.h (100%) rename onnxruntime/{contrib_ops/cuda => core/providers/cuda/tensor}/grid_sample_impl.cu (100%) rename onnxruntime/{contrib_ops/cuda => core/providers/cuda/tensor}/grid_sample_impl.h (100%) diff --git a/onnxruntime/contrib_ops/cuda/grid_sample.cc b/onnxruntime/core/providers/cuda/tensor/grid_sample.cc similarity index 100% rename from onnxruntime/contrib_ops/cuda/grid_sample.cc rename to onnxruntime/core/providers/cuda/tensor/grid_sample.cc diff --git a/onnxruntime/contrib_ops/cuda/grid_sample.h b/onnxruntime/core/providers/cuda/tensor/grid_sample.h similarity index 100% rename from onnxruntime/contrib_ops/cuda/grid_sample.h rename to onnxruntime/core/providers/cuda/tensor/grid_sample.h diff --git a/onnxruntime/contrib_ops/cuda/grid_sample_impl.cu b/onnxruntime/core/providers/cuda/tensor/grid_sample_impl.cu similarity index 100% rename from onnxruntime/contrib_ops/cuda/grid_sample_impl.cu rename to onnxruntime/core/providers/cuda/tensor/grid_sample_impl.cu diff --git a/onnxruntime/contrib_ops/cuda/grid_sample_impl.h b/onnxruntime/core/providers/cuda/tensor/grid_sample_impl.h similarity index 100% rename from onnxruntime/contrib_ops/cuda/grid_sample_impl.h rename to onnxruntime/core/providers/cuda/tensor/grid_sample_impl.h