CUDA development (on any platform) requires both the nvcc
compiler as well as a suitable host code compiler. On (native, not WSL2) Windows, the only host compiler supported for CUDA development is cl.exe
- the host code compiler that ships with Visual Studio.
So to provide a proper environment for CUDA development on (native, not WSL2) Windows, you must install Visual Studio.
Other than that, follow the instructions provided by NVIDIA to get things set up.
An important aspect of those instructions is to install (a supported version of) Visual Studio first, then run the CUDA installer. In this way, the CUDA installer locates all supported versions of Visual Studio, and performs additional integration steps necessary to have a sane compilation environment for Windows.
After you have done that, if you intend to compile from the command line, you may still need to set your PATH
environment variable correctly, and also be sure to use the -ccbin
switch for nvcc
to specify the location of cl.exe
. Both location methods are necessary, in the general case, when compiling from the command line.