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
This commit is contained in:
Daniel Fullmer
2026-09-10 21:42:02 -07:00
parent 12a8535d14
commit 529639f532
2 changed files with 23 additions and 0 deletions

View File

@@ -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

View File

@@ -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")