From c78f5f413fd0f8e0a682b3a1e8a93966e0cfb26b Mon Sep 17 00:00:00 2001 From: Daniel Fullmer Date: Sun, 28 Jun 2026 16:11:31 -0700 Subject: [PATCH] onnxruntime: fix CUDAExecutionProvider loading error onnxruntime fails to load the CUDAExecutionProvider with an libonnxruntime_providers_cuda.so: undefined symbol: nvrtcGetProgramLogSize error. cudnn-frontend >=1.19.0 now includes symbols provided by nvrtc but does not ensure it is linked against it. Recent commits to onnxruntime add the CUDA::nvrtc link target to resolve the issue. This adds the same change here. --- pkgs/by-name/on/onnxruntime/nvrtc-link.patch | 26 ++++++++++++++++++++ pkgs/by-name/on/onnxruntime/package.nix | 6 +++++ 2 files changed, 32 insertions(+) create mode 100644 pkgs/by-name/on/onnxruntime/nvrtc-link.patch diff --git a/pkgs/by-name/on/onnxruntime/nvrtc-link.patch b/pkgs/by-name/on/onnxruntime/nvrtc-link.patch new file mode 100644 index 000000000000..8c83c364498a --- /dev/null +++ b/pkgs/by-name/on/onnxruntime/nvrtc-link.patch @@ -0,0 +1,26 @@ +diff --git a/cmake/onnxruntime_providers_cuda.cmake b/cmake/onnxruntime_providers_cuda.cmake +index 624057dd43..64de9a0860 100644 +--- a/cmake/onnxruntime_providers_cuda.cmake ++++ b/cmake/onnxruntime_providers_cuda.cmake +@@ -310,7 +310,7 @@ + message( WARNING "To compile with NHWC ops enabled please compile against cuDNN 9 or newer." ) + endif() + endif() +- target_link_libraries(${target} PRIVATE CUDA::cublasLt CUDA::cublas CUDNN::cudnn_all cudnn_frontend CUDA::curand CUDA::cufft CUDA::cudart ++ target_link_libraries(${target} PRIVATE CUDA::cublasLt CUDA::cublas CUDNN::cudnn_all cudnn_frontend CUDA::curand CUDA::cufft CUDA::cudart CUDA::nvrtc CUDA::cuda_driver + ${ABSEIL_LIBS} ${ONNXRUNTIME_PROVIDERS_SHARED} Boost::mp11 safeint_interface) + endif() + +diff --git a/cmake/onnxruntime_providers_cuda_plugin.cmake b/cmake/onnxruntime_providers_cuda_plugin.cmake +index e345c944dc..82742df359 100644 +--- a/cmake/onnxruntime_providers_cuda_plugin.cmake ++++ b/cmake/onnxruntime_providers_cuda_plugin.cmake +@@ -250,6 +250,8 @@ target_link_libraries(onnxruntime_providers_cuda_plugin PRIVATE + CUDA::cublas + CUDA::cublasLt + CUDA::cufft ++ CUDA::nvrtc ++ CUDA::cuda_driver + CUDNN::cudnn_all + cudnn_frontend + Boost::mp11 diff --git a/pkgs/by-name/on/onnxruntime/package.nix b/pkgs/by-name/on/onnxruntime/package.nix index 4253d258d8b2..7f8eb893fb6f 100644 --- a/pkgs/by-name/on/onnxruntime/package.nix +++ b/pkgs/by-name/on/onnxruntime/package.nix @@ -132,6 +132,12 @@ effectiveStdenv.mkDerivation (finalAttrs: { # https://github.com/microsoft/onnxruntime/issues/9155 # Patch adapted from https://gitlab.alpinelinux.org/alpine/aports/-/raw/462dfe0eb4b66948fe48de44545cc22bb64fdf9f/community/onnxruntime/0001-Remove-MATH_NO_EXCEPT-macro.patch ./remove-MATH_NO_EXCEPT-macro.patch + ] + # Include additional target_link_libraries needed for cudnn-frontend >= 2.19 + # See: https://github.com/microsoft/onnxruntime/pull/28849 + # These changes are included in 548ab6e and fc7a9f0 upstream + ++ lib.optionals cudaSupport [ + ./nvrtc-link.patch ]; postPatch = ''