From 529639f53259cc4889f8f243a4bb50f032ffc566 Mon Sep 17 00:00:00 2001 From: Daniel Fullmer Date: Thu, 10 Sep 2026 21:42:02 -0700 Subject: [PATCH] ctranslate2: explicitly set nvcc -gencode flags This fixes a build failure when using cudaPackages_13: > Unsupported gpu architecture 'compute_53' Verified builds both with and without `cudaPackages = cudaPackages_13` override, on x86_64-linux and aarch64-linux --- .../ct/ctranslate2/cuda-arch-gencode-flags.patch | 11 +++++++++++ pkgs/by-name/ct/ctranslate2/package.nix | 12 ++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 pkgs/by-name/ct/ctranslate2/cuda-arch-gencode-flags.patch diff --git a/pkgs/by-name/ct/ctranslate2/cuda-arch-gencode-flags.patch b/pkgs/by-name/ct/ctranslate2/cuda-arch-gencode-flags.patch new file mode 100644 index 000000000000..1a47dc6c261f --- /dev/null +++ b/pkgs/by-name/ct/ctranslate2/cuda-arch-gencode-flags.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -538,8 +538,6 @@ + list(REMOVE_DUPLICATES CUDA_ARCH_LIST) + endif() + +- cuda_select_nvcc_arch_flags(ARCH_FLAGS ${CUDA_ARCH_LIST}) +- list(APPEND CUDA_NVCC_FLAGS ${ARCH_FLAGS}) + set(CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER}) + + # flags for flash attention diff --git a/pkgs/by-name/ct/ctranslate2/package.nix b/pkgs/by-name/ct/ctranslate2/package.nix index 2dc1f3494512..e5a89acd34d8 100644 --- a/pkgs/by-name/ct/ctranslate2/package.nix +++ b/pkgs/by-name/ct/ctranslate2/package.nix @@ -65,6 +65,15 @@ stdenv'.mkDerivation (finalAttrs: { hash = "sha256-OuN7GTfzqsALu8Qgx7GNERlyCq3cTxhpZo8UA/yDekw="; }; + patches = [ + # ctranslate2 uses a deprecated cmake FindCUDA cuda_select_nvcc_arch_flags() + # function. This function uses a regex that can not match two-digit + # capabilities such as 10.0 and 12.1, and it's default "Auto" fallback still + # targets compute_53, which CUDA 13 no longer supports, so the patch removes + # its arch selection, and we set CUDA_NVCC_FLAGS ourselves below. + ./cuda-arch-gencode-flags.patch + ]; + # Fix CMake 4 compatibility postPatch = '' substituteInPlace third_party/cpu_features/CMakeLists.txt \ @@ -103,6 +112,9 @@ stdenv'.mkDerivation (finalAttrs: { (lib.cmakeBool "WITH_MKL" withMkl) (lib.cmakeBool "WITH_HIP" rocmSupport) ] + ++ lib.optionals withCUDA [ + (lib.cmakeFeature "CUDA_NVCC_FLAGS" (lib.concatStringsSep ";" cudaPackages.flags.gencode)) + ] ++ lib.optionals rocmSupport [ (lib.cmakeBool "CMAKE_SKIP_RPATH" true) (lib.cmakeFeature "CMAKE_C_COMPILER" "amdclang")