Skip to content

CMake cannot detect a default CUDA architecture with SCALE's nvcc #53

Description

@diskdog

SCALE 1.7.1 and the 2026.07.02 nightly (same failure), NVIDIA target, CMake 3.28, CUDA 13.1 toolkit on the host.

Configuring any CUDA project that does not pin CMAKE_CUDA_ARCHITECTURES fails at the configure step when SCALE's nvcc is substituted the usual way:

cmake_minimum_required(VERSION 3.18)
project(mini LANGUAGES CXX CUDA)
add_executable(mini main.cu)
cmake -S . -B build -DCMAKE_CUDA_COMPILER=$SCALE/llvm/bin/nvcc

CMake Error at /usr/share/cmake-3.28/Modules/CMakeDetermineCUDACompiler.cmake:270 (message):
  Failed to detect a default CUDA architecture.

The same CMakeLists configures and builds fine with NVIDIA's nvcc and no extra variables. The documented scaleenv path works because it sets up two things the detection needs: it exports CUDAARCHS (which pre-pins CMAKE_CUDA_ARCHITECTURES so the arch detection never runs) and it puts SCALE's llvm/bin on PATH. Anyone driving cmake with -DCMAKE_CUDA_COMPILER= (the standard way to swap a CUDA compiler, and all a project needs with real nvcc) hits the error.

Cause: CMake identifies SCALE's nvcc as an NVIDIA compiler and derives the default architecture by regexing the -v verbose output for -arch compute_([0-9]+) (Modules/Internal/CMakeNVCCParseImplicitInfo.cmake:32). Real nvcc prints -arch compute_75 on its cicc line. SCALE's emulated #$ verbose output never emits an -arch compute_XX token, although it knows the target (its ptxas line says --gpu-name sm_75), so the regex matches nothing and CMake gives up.

Emitting the -arch compute_XX token in the verbose output, matching nvcc's format, would make unmodified cmake projects configure. Workaround for users: pin the architecture (CUDAARCHS=75 or -DCMAKE_CUDA_ARCHITECTURES=75) and keep SCALE's llvm/bin on PATH. With the arch pinned but llvm/bin off PATH, configure gets past detection and then fails at the try-compile link step with Error running link command: No such file or directory, because the link launcher SCALE reports resolves to a bare clang++. Activating scaleenv is the clean way to get both.

Found via the validation sweep's whole-project build differential: 8 cmake projects (casadi-on-gpu, csrspmm, qwen600, SGEMM_CUDA, sm75-tensorcore-microkernel, Tinyforge, video-to-3d-cuda, ztree-pca-normals) all fail configure this way, while projects that pin CMAKE_CUDA_ARCHITECTURES in their CMakeLists configure fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions