CUDA ERROR
No CMAKE_CUDA_COMPILER could be found: the CMake CUDA family
Four CMake messages, four causes. On CMake 4.4 we got Failed to find nvcc, and one attempt to scrub the environment did not reproduce it.
CMake tried to turn on the CUDA language, went looking for a compiler and a toolkit, and gave up. Which of four messages you get tells you which half it could not find.
| Kind | Build system. No cudaError code |
| Captured with | CMake 4.4, CUDA 12.6 (V12.6.85), 2026-09-01 |
| Source | code/errors/_toolchain/evidence/run-2026-09-01.txt |
What we measured, which is not the message the search term names
The project under test is two lines, cmake_minimum_required(VERSION 3.20) and project(demo LANGUAGES CUDA). We tried to break it twice. From code/errors/_toolchain/evidence/run-2026-09-01.txt:
== cmake cannot find CUDA (CUDACXX unset, nvcc off PATH) ==
$ env -u CUDACXX PATH=/usr/bin:/bin /tmp/100dc/bin/cmake -S . -B build
exit: 0
That first attempt succeeded. Removing nvcc from PATH and unsetting CUDACXX was not enough to hide the toolkit, because CMake has other ways to find it and the surrounding environment still carried one. Worth knowing before you spend an afternoon convinced your PATH is the problem.
Scrubbing the environment completely did reproduce a failure, and the message is not the one everybody searches for:
$ env -i PATH=/usr/bin:/bin HOME=$HOME /tmp/100dc/bin/cmake -S . -B build
CMake Error at /tmp/100dc/share/cmake-4.4/Modules/Internal/CMakeCUDAFindToolkit.cmake:104 (message):
Failed to find nvcc.
Compiler requires the CUDA toolkit. Please set the CUDAToolkit_ROOT
variable.
Call Stack (most recent call first):
/tmp/100dc/share/cmake-4.4/Modules/CMakeDetermineCUDACompiler.cmake:109 (cmake_cuda_find_toolkit)
CMakeLists.txt:2 (project)
On CMake 4.4 the diagnostic for a missing toolkit is Failed to find nvcc. and the variable it names is CUDAToolkit_ROOT. The famous No CMAKE_CUDA_COMPILER could be found. belongs to older CMake and to a slightly different failure point. If you are on a recent CMake, search for the string you actually got, and note that the two-space indentation and the double space before "Please" are CMake's own formatting.
Read the call stack from the bottom. CMakeLists.txt:2 is the project() line, which is where CUDA detection runs, so a missing toolkit fails at project configuration rather than at your first target.
Cause 1: no nvcc anywhere CMake looks
The measured case. CMake searches PATH, the CUDACXX environment variable, CUDAToolkit_ROOT, and $ENV{CUDA_PATH}/bin. Only when all of them come up empty does it fail, which is why our half-scrubbed first attempt still worked.
Fix, in order of preference: put the toolkit's bin on PATH for good; or set CUDAToolkit_ROOT as the message asks; or pass the compiler explicitly, cmake -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc ...
Cause 2: Failed to detect a default CUDA architecture
Documented, not captured here. Modern CMake insists on knowing which GPU architecture to build for, and this message means it could not pick one, usually because the host compiler is broken or CMAKE_CUDA_ARCHITECTURES is unset. Emitted from CMakeDetermineCUDACompiler.cmake (https://github.com/Kitware/CMake/blob/master/Modules/CMakeDetermineCUDACompiler.cmake , checked 2026-08-29).
Fix: set(CMAKE_CUDA_ARCHITECTURES 75) in the CMakeLists, or -DCMAKE_CUDA_ARCHITECTURES=75. This course's floor is 75; day 69 covers building a multi-architecture list properly.
Cause 3: No CUDA toolset found
Documented, not captured, and Windows only. With the Visual Studio generator, CMake needs the CUDA installer's MSBuild integration files in Visual Studio's build customisations directory. Installing CUDA before Visual Studio, or adding a second Visual Studio afterwards, leaves them in the wrong place. Emitted from CMakeDetermineCompilerId.cmake when CMAKE_VS_PLATFORM_TOOLSET_CUDA is empty (https://github.com/Kitware/CMake/blob/master/Modules/CMakeDetermineCompilerId.cmake , checked 2026-08-29).
Fix: reinstall the toolkit's Visual Studio integration component, or copy the CUDA .props and .targets files into BuildCustomizations.
Cause 4: is not able to compile a simple test program
Documented, not captured. nvcc was found and then failed its smoke test, which nearly always means the host compiler was rejected rather than anything about CUDA. Emitted from CMakeTestCUDACompiler.cmake (https://github.com/Kitware/CMake/blob/master/Modules/CMakeTestCUDACompiler.cmake , checked 2026-08-29).
Fix: read the compiler output CMake prints underneath the message, which contains the real error, and set CMAKE_CUDA_HOST_COMPILER at a version the toolkit supports.
Confirm which one you have
Read CMakeFiles/CMakeError.log and CMakeFiles/CMakeOutput.log in the build directory. The configure-time message is a summary; those logs hold the command that failed and its output.
Then check the obvious thing our first attempt proves is not obvious: run which nvcc in the same shell, with the same environment, that you run cmake in. A wrapper script, an IDE, or a scheduler can hand CMake an environment that is nothing like your terminal's.
One more: FindCUDA is deprecated. Use enable_language(CUDA) and find_package(CUDAToolkit) (https://cmake.org/cmake/help/latest/module/FindCUDAToolkit.html , checked 2026-08-29). Any answer telling you to set CUDA_TOOLKIT_ROOT_DIR is fixing the old module and will not help.
Prevention
- Set
CMAKE_CUDA_ARCHITECTURESin the CMakeLists rather than on the command line, so a fresh clone configures without arguments. - Keep the toolkit on
PATHin the profile, not in one shell, and remember that whatever launches your build may not read that profile at all.
Related errors
nvcc: command not found, but nvidia-smi works: the same absence, reported by the shell instead of by CMake.fatal error: cuda_runtime.h: No such file or directory: the include-path half of the same problem.nvcc fatal: Unsupported gpu architecture: what a wrongCMAKE_CUDA_ARCHITECTURESvalue gets you once configuration succeeds.
The lesson
Day 67 builds this project's CUDA CMake setup from scratch, including separable compilation and the architecture list. Day 69 covers targeting more than one card. Installation lives at /setup/install-cuda, and the full code table is on the error hub.
Written 2026-09-01. CMake output from code/errors/_toolchain/evidence/run-2026-09-01.txt, captured 2026-09-01 with CMake 4.4 and CUDA 12.6 (V12.6.85) on ornn-internal-t4-spot-5v08. Causes 2, 3 and 4 are sourced from CMake's own modules and were not reproduced on this node; the page says so rather than inventing transcripts. Author and reviewer: not yet assigned; this page does not publish until both are named.