I just ran into this in Visual Studio 2017 and Cuda v9.0, trying to compile from the command line using nvcc . After a lengthy session, I realized that my Visual Studio command-line tools were configured to use cl.exe from the x86 director instead of x64 . There are several ways to solve it, one way is to override the directory in which it searches for its compiler tools, for example, for example:
nvcc -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\bin\HostX86\x64" -o add_cuda add_cuda.cu
Then it worked fine.
I also mentioned that I used which.exe utility from git tools to find out which version of cl.exe it was cl.exe , but the where command, which is native to windows, works.
Update:
Another way — perhaps the best way — is to simply set the Visual Studio environment variables correctly to 64 bits, as is the case for the Enterprise version:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
For the community version, replace "Community" with "Enterprise" along the way.
You can also select a toolbox with (for example) --vcvars_ver=14.0 , which selects the toolbox 14.0 needed to compile CUDA 9.1 with Visual Studio version 15.5.
Then you can simply create this:
nvcc -o add_cuda add_cuda.cu
source share