If I have two CUDA toolkits installed say 12.2 and 12.3 the default Visual Studio behaviour appears to be to use CUDA 12.3, how can I generate a Visual Studio project which uses CUDA toolkit 12.2 when CUDA is a first class language?
If I use the ninja generator then adding C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2/bin to the begining of the system/user PATH environmental variable will select 12.2, however this does not work for the Visual Studio generator.
If I use Visual Studio generator it seems that the path to CUDA is determined by the CUDA_PATH_V12_3 environmental variable. That is if this is set this to to C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2 CMake detects CUDA 12.2 and outputs
– Looking for a CUDA compiler
– Looking for a CUDA compiler - C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2/bin/nvcc.exe
– The CUDA compiler identification is NVIDIA 12.2.128
however if I delete this environmental variable, even if there is a CUDA_PATH and CUDA_PATHV12_2 environmental variable pointing to the same place and the directory containing the compiler is on the PATH the CUDA toolkit is not found.