Cmake & CUDA : The CUDA Toolkit v12.2 directory '' does not exist Error

I’m trying to build a project that uses CUDA with Cmake. However, when generating (and building), the following errors get output:
E:\Visual Studio 2019\IDE\MSBuild\Microsoft\VC\v160\BuildCustomizations\CUDA 12.2.targets(606,9): error : The CUDA Toolkit v12.2 directory '' does not exist. Please verify the CUDA Toolkit is installed properly or define the CudaToolkitDir property to resolve this error. [G:\[...]\build\CMakeFiles\3.27.4\CompilerIdCUDA\CompilerIdCUDA.vcxproj]
This happens not matter whether I build with VS2019 or 2022. I have reinstalled CUDA numerous times.
This is the cmake command I used, in which I already tried to override the Toolkit directory:
cmake -B "../build" -G "Visual Studio 16" -D WITH_MT=ON -D CUDA_TOOLKIT_ROOT_DIR="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2"

Is anyone aware of how to solve this issue? It is not possible for me to change this in Visual Studio as the only other person on the forums with this issue found, as this happens during the Cmake setup step.

Figured it out - the issue was that I was using the regular Windows Command Prompt. When using the x64 Native Tools Command Prompt and running Cmake for the build, the build works out.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.