Skip to content

Confusing error message and inappropriate followup action when CUDA compiler is missing

Using CMake 3.29.0-rc1.

With the following list file:

cmake_minimum_required(VERSION 3.25)
project(foo CUDA)

and invoking:

$ cmake -B build -DCMAKE_CUDA_COMPILER=/usr/local/cuda-12.34.no-such-version/bin/nvcc

I see this:

-- The CUDA compiler identification is unknown
CMake Error at /opt/versions/cmake/3.29.0-rc1/share/cmake-3.29/Modules/CMakeDetermineCUDACompiler.cmake:266 (message):
  Failed to detect a default CUDA architecture.



  Compiler output:

Call Stack (most recent call first):
  CMakeLists.txt:2 (project)

This is a poor combination of error messages:

  • The first line suggest a CUDA compiler does exist, but is just of "unknown identification" - which is not the case, it's simply not at the specified path.
  • The second warning suggests some kind of procedure was undertaken to detect the default CUDA architecture, but actually, it wasn't, since that procedure requires a CUDA compiler, which isn't there

instead, I expect to be told that the CUDA compiler was not found; and then, I expect CMake not try to detect the CUDA architecture, given that CMake knows that the detection requires the CUDA compiler.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information