I had the same problem. The operating system was Windows 7 64-bit and I had installed both the 64-bit versions of the CUDA toolkit (and of the GPU Computing SDK code samples) and of the Windows SDK. At that point I expected to be able to setup a Visual C++ environment through vcvars32.bat or vcvars64.bat and run nvcc, but I got the same error message that you did.
I then installed Visual C++ 2008 Express (as well as the 2010 by mistake; it shouldn’t make a difference) and the error message changed to:
At that point it would have been possible for me to compile a 32-bit executable by passing nvcc the -m32 option, though I only realized so later. (Trial and error seem to show that there is no need to change the CUDA environment variables to point to the 32-bit directories in order compiling. However, it is necessary to change the PATH so that it points to C:\CUDA\bin.)
I later used some of Dr.Synth’s suggestions: I created a vcvarsamd64.bat file (which can be empty: its contents seem to be irrelevant) under “C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64”. From then on I seem to be able to target 64-bit builds from the command line. His other suggestions should allow you to build under Visual C++ too.
Those error messages are quite misleading. To check which files nvcc is failing to open you might want to try out Process Monitor. With it you can do the following:
Run Process Monitor.
Inside it, create a filter targeting nvcc (e.g. filter by process name nvcc.exe).
Again inside it, clear the captured events to have a clear view.
Launch nvcc to trip the error and capture the events.
Examine the bottom of the list of captured events to find which file failed to load (at the top of it you will find likely find many unrelated failures, such as the PATH search for some files
This was how I found that, when installing the Microsoft C/C++ 32 and 64 bit compilers through the VS2008-compatible Windows 7 SDK there were two files which the 64-bit version of nvcc wanted:
[font=“Courier New”]C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat[/font]. To make things work, I created the missing directory, copied into it [font=“Courier New”]C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat[/font] and renamed the copied file.
[font=“Courier New”]C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\vcvarsamd64.bat[/font]. I “solved” this issue by copying into that directory [font=“Courier New”]C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars64.bat[/font] and renaming the copied file.