Skip to content

ctranslate2: don't set default nvcc arch flags#536525

Merged
mweinelt merged 1 commit into
NixOS:masterfrom
danielfullmer:ctranslate2-cuda-arch
Jun 29, 2026
Merged

ctranslate2: don't set default nvcc arch flags#536525
mweinelt merged 1 commit into
NixOS:masterfrom
danielfullmer:ctranslate2-cuda-arch

Conversation

@danielfullmer

Copy link
Copy Markdown
Contributor

This fixes a build failure when using cudaPackages_13:

Unsupported gpu architecture 'compute_53'

Build failure originally reproduced with:

nix build -f =(echo 'with (import (builtins.getFlake "nixpkgs/nixos-unstable")  { config = { cudaSupport = true; allowUnfree=true; }; }).extend (final: prev: { cudaPackages = final.cudaPackages_13; }); ctranslate2' )

Things done

This fixes a build failure when using cudaPackages_13:

> Unsupported gpu architecture 'compute_53'
@nixpkgs-ci
nixpkgs-ci Bot requested review from misuzu and mweinelt June 29, 2026 04:12
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. labels Jun 29, 2026
@mweinelt
mweinelt added this pull request to the merge queue Jun 29, 2026
Merged via the queue into NixOS:master with commit fbaf99e Jun 29, 2026
28 checks passed
@ConnorBaker

Copy link
Copy Markdown
Contributor

How are the desired set of CUDA capabilities passed to CMake?

I would have expected setting CUDA_ARCH_LIST in cmakeFlagsArray (contains whitespace, cmakeFlags if structured attributes are enabled) using some of the values from cudaPackages.flags.

@danielfullmer

Copy link
Copy Markdown
Contributor Author

They use the deprecated FindCuda cmake module, specifically the cuda_select_nvcc_arch_flags() described here: https://cmake.org/cmake/help/latest/module/FindCUDA.html

https://github.com/OpenNMT/CTranslate2/blob/e23a925508612a754e46242cb07a6c84bef56521/CMakeLists.txt#L541

As far as I can see, the format cuda_select_nvcc_arch_flags() accepts doesn't match any currently available thing under flags.*. cmakeCudaArchitecturesString is for CMAKE_CUDA_ARCHITECTURES, which is slightly different than cuda_select_nvcc_arch_flags. I could try to come up with some logic to set cuda_select_nvcc_arch_flags correctly, but since it's deprecated, I didn't want to put too much unnecessary effort into it if it's going away.

By the way, is there a standard for when/if we should set the CUDA architectures in build systems? Is it just if it's convenient and someone remembers to? Or are you trying to be more complete?

@ConnorBaker

Copy link
Copy Markdown
Contributor

This should work:

cmakeFlags = ... ++ [ (lib.cmakeFeature "CUDA_ARCH_LIST" (builtins.toString cudaPackages.flags.cudaCapabilities) ]

(use cudaPackages.flags.cudaCapabilities instead of config.cudaCapabilities because the default set of capabilities depends on the version of the CUDA package set being used and so can't be populated as a global default value; also the order of resolution of config in the fixed point is odd).

CUDA architectures should always be provided to the build system when CUDA support is enabled.

@danielfullmer

Copy link
Copy Markdown
Contributor Author

I get the following error when setting CUDA_ARCH_LIST:

CMake Error at /nix/store/k1b82rs72af124wmq6nb00nhw5i7ikp7-cmake-4.1.2/share/cmake-4.1/Modules/FindCUDA/select_compute_arch.cmake:245 (message):
  Unknown CUDA Architecture Name 10.0 in CUDA_SELECT_NVCC_ARCH_FLAGS
Call Stack (most recent call first):
  CMakeLists.txt:541 (cuda_select_nvcc_arch_flags)


CMake Error at /nix/store/k1b82rs72af124wmq6nb00nhw5i7ikp7-cmake-4.1.2/share/cmake-4.1/Modules/FindCUDA/select_compute_arch.cmake:249 (message):
  arch_bin wasn't set for some reason
Call Stack (most recent call first):
  CMakeLists.txt:541 (cuda_select_nvcc_arch_flags)


CMake Error at /nix/store/k1b82rs72af124wmq6nb00nhw5i7ikp7-cmake-4.1.2/share/cmake-4.1/Modules/FindCUDA/select_compute_arch.cmake:245 (message):
  Unknown CUDA Architecture Name 10.3 in CUDA_SELECT_NVCC_ARCH_FLAGS
Call Stack (most recent call first):
  CMakeLists.txt:541 (cuda_select_nvcc_arch_flags)


CMake Error at /nix/store/k1b82rs72af124wmq6nb00nhw5i7ikp7-cmake-4.1.2/share/cmake-4.1/Modules/FindCUDA/select_compute_arch.cmake:249 (message):
  arch_bin wasn't set for some reason
Call Stack (most recent call first):
  CMakeLists.txt:541 (cuda_select_nvcc_arch_flags)


CMake Error at /nix/store/k1b82rs72af124wmq6nb00nhw5i7ikp7-cmake-4.1.2/share/cmake-4.1/Modules/FindCUDA/select_compute_arch.cmake:245 (message):
  Unknown CUDA Architecture Name 12.0 in CUDA_SELECT_NVCC_ARCH_FLAGS
Call Stack (most recent call first):
  CMakeLists.txt:541 (cuda_select_nvcc_arch_flags)


CMake Error at /nix/store/k1b82rs72af124wmq6nb00nhw5i7ikp7-cmake-4.1.2/share/cmake-4.1/Modules/FindCUDA/select_compute_arch.cmake:249 (message):
  arch_bin wasn't set for some reason
Call Stack (most recent call first):
  CMakeLists.txt:541 (cuda_select_nvcc_arch_flags)


CMake Error at /nix/store/k1b82rs72af124wmq6nb00nhw5i7ikp7-cmake-4.1.2/share/cmake-4.1/Modules/FindCUDA/select_compute_arch.cmake:245 (message):
  Unknown CUDA Architecture Name 12.1 in CUDA_SELECT_NVCC_ARCH_FLAGS
Call Stack (most recent call first):
  CMakeLists.txt:541 (cuda_select_nvcc_arch_flags)


CMake Error at /nix/store/k1b82rs72af124wmq6nb00nhw5i7ikp7-cmake-4.1.2/share/cmake-4.1/Modules/FindCUDA/select_compute_arch.cmake:249 (message):
  arch_bin wasn't set for some reason
Call Stack (most recent call first):
  CMakeLists.txt:541 (cuda_select_nvcc_arch_flags)

It looks like FindCUDA doesn't even accept double digit major version numbers based on the regex here. I assume they just arent putting in any additional effort to FindCUDA given that it's deprecated.

@danielfullmer

Copy link
Copy Markdown
Contributor Author

Also, it looks like there's ongoing work to migrate to the newer cmake support here: OpenNMT/CTranslate2#2067

gshpychka added a commit to gshpychka/nixpkgs that referenced this pull request Jul 1, 2026
The package uses CMake's legacy FindCUDA module, whose cuda_add_library
reads GPU arch flags only from CUDA_NVCC_FLAGS and ignores the
CMAKE_CUDA_ARCHITECTURES set by setupCudaHook. Since NixOS#536525 stopped
populating CUDA_NVCC_FLAGS, nvcc falls back to its default (sm_52 on
CUDA 12) and the fp16 AWQ kernels fail ptxas (need sm_53+). Feed the
configured gencode flags directly.
@mweinelt

mweinelt commented Jul 1, 2026

Copy link
Copy Markdown
Member

Based on the build failure issues linked I'm inclined to revert.

@mweinelt

mweinelt commented Jul 1, 2026

Copy link
Copy Markdown
Member

Feel free to resubmit when the CUDA issues are settled.

SuperSandro2000 pushed a commit to SuperSandro2000/nixpkgs that referenced this pull request Jul 1, 2026
The package uses CMake's legacy FindCUDA module, whose cuda_add_library
reads GPU arch flags only from CUDA_NVCC_FLAGS and ignores the
CMAKE_CUDA_ARCHITECTURES set by setupCudaHook. Since NixOS#536525 stopped
populating CUDA_NVCC_FLAGS, nvcc falls back to its default (sm_52 on
CUDA 12) and the fp16 AWQ kernels fail ptxas (need sm_53+). Feed the
configured gencode flags directly.
SuperSandro2000 pushed a commit to SuperSandro2000/nixpkgs that referenced this pull request Jul 1, 2026
The package uses CMake's legacy FindCUDA module, whose cuda_add_library
reads GPU arch flags only from CUDA_NVCC_FLAGS and ignores the
CMAKE_CUDA_ARCHITECTURES set by setupCudaHook. Since NixOS#536525 stopped
populating CUDA_NVCC_FLAGS, nvcc falls back to its default (sm_52 on
CUDA 12) and the fp16 AWQ kernels fail ptxas (need sm_53+). Feed the
configured gencode flags directly.
SuperSandro2000 pushed a commit to SuperSandro2000/nixpkgs that referenced this pull request Jul 3, 2026
The package uses CMake's legacy FindCUDA module, whose cuda_add_library
reads GPU arch flags only from CUDA_NVCC_FLAGS and ignores the
CMAKE_CUDA_ARCHITECTURES set by setupCudaHook. Since NixOS#536525 stopped
populating CUDA_NVCC_FLAGS, nvcc falls back to its default (sm_52 on
CUDA 12) and the fp16 AWQ kernels fail ptxas (need sm_53+). Feed the
configured gencode flags directly.
SuperSandro2000 pushed a commit to SuperSandro2000/nixpkgs that referenced this pull request Jul 4, 2026
The package uses CMake's legacy FindCUDA module, whose cuda_add_library
reads GPU arch flags only from CUDA_NVCC_FLAGS and ignores the
CMAKE_CUDA_ARCHITECTURES set by setupCudaHook. Since NixOS#536525 stopped
populating CUDA_NVCC_FLAGS, nvcc falls back to its default (sm_52 on
CUDA 12) and the fp16 AWQ kernels fail ptxas (need sm_53+). Feed the
configured gencode flags directly.
SuperSandro2000 pushed a commit to SuperSandro2000/nixpkgs that referenced this pull request Jul 4, 2026
The package uses CMake's legacy FindCUDA module, whose cuda_add_library
reads GPU arch flags only from CUDA_NVCC_FLAGS and ignores the
CMAKE_CUDA_ARCHITECTURES set by setupCudaHook. Since NixOS#536525 stopped
populating CUDA_NVCC_FLAGS, nvcc falls back to its default (sm_52 on
CUDA 12) and the fp16 AWQ kernels fail ptxas (need sm_53+). Feed the
configured gencode flags directly.
SuperSandro2000 pushed a commit to SuperSandro2000/nixpkgs that referenced this pull request Jul 4, 2026
The package uses CMake's legacy FindCUDA module, whose cuda_add_library
reads GPU arch flags only from CUDA_NVCC_FLAGS and ignores the
CMAKE_CUDA_ARCHITECTURES set by setupCudaHook. Since NixOS#536525 stopped
populating CUDA_NVCC_FLAGS, nvcc falls back to its default (sm_52 on
CUDA 12) and the fp16 AWQ kernels fail ptxas (need sm_53+). Feed the
configured gencode flags directly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants