NVCC error: Only MSVC 8.0 and MSVC 9.0 are supported. But MSVC 9.0 _is_ installed and in path

How does nvcc decide what is an acceptable compiler (cl.exe) version? I’m getting errors that I need msvc 8 or 9 installed, but it is in fact installed (the express version + the 6.1 windows sdk). I’m running on a 64-bit os, but I’ve experienced the same problem whether I run from a 32-bit or 64-bit command window.

Here is the command line I’m running:
C:\tools\cudasdk\projects\BlackScholes>c:\tools\cuda\bin\nvcc.exe BlackScholes.cu
nvcc fatal : nvcc cannot find a supported cl version. Only MSVC 8.0 and MSVC 9.0 are supported

I get the same error when using cl from C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\cl.exe and C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\cl.exe
I’ve also tried adding cl.exe to the path explicitly with the --ccbin arg. No luck.

Actual version of cl is:
Microsoft ® 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
64-bit version is:
Microsoft ® C/C++ Optimizing Compiler Version 15.00.21022.08 for x64

nvcc version is Cuda compilation tools, release 2.1, V0.2.1221.

Anyone else seen this or have a workaround? I saw a link to a .bat file to throw in the amd64 directory-- tried that, no help.

thanks
-jordan

Just to make sure, is the Visual Studio build environment set up in your command line? Try running “C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat” in your command window before building with nvcc.

I made a simple little batch script that automatically sets up a CUDA build environment and builds a single .cu file that works for my needs. You might try it on your system. It will also automatically call the vsvars32.bat if it detects that it has not been run yet.

Note that I hard coded a few paths to the C: drive, but the installation directories are the defaults. Also, I’m running Vista x64, but I installed the 32-bit SDK, so this is a 32-bit build environment.

@echo off

setlocal EnableDelayedExpansion

REM ******************************************************

REM  Batch script for building CUDA code files

REM ******************************************************

REM if we haven't yet set up the VS build environment, do so here

if "%DevEnvDir%" EQU "" (

   call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat"

)

if "%1" EQU "" (

   echo.

   echo Usage:

   echo.

   echo	%0 ^<codefile.cu^>

   echo.

   echo This batch script compiles .cu files into executables.

   echo.

   goto :EOF

)

REM get the base file name from the input file name

for %%a in (%1) do @set CUFILE=%%~na

if not exist %CUFILE%.cu (

   echo File not found.

   goto :EOF

)

echo Building %CUFILE%.cu ...

set NVCC="C:\CUDA\bin\nvcc.exe"

set CCBIN=-ccbin "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin"

set CCOPTS=-Xcompiler "/EHsc /W3 /nologo /Od /Zi   /MTd  "

set INCOPTS=-IC:\CUDA\include

set ARCHOPTS=-arch sm_10

set NVOPTS=-maxrregcount=32  --compile

set OBJ=%CUFILE%.obj

set CU=%CUFILE%.cu

if exist %OBJ% del /f /q %OBJ%

%NVCC% %ARCHOPTS% %CCBIN% %CCOPTS% %INCOPTS% %NVOPTS% -o %OBJ% %CU%

if not exist %OBJ% goto :EOF

set CUDALIBS=cudart.lib cutil32D.lib

set LIBPATHS=/libpath:C:\CUDA\lib

set LIBPATHS=%LIBPATHS% /libpath:"C:\ProgramData\NVIDIA Corporation\NVIDIA CUDA SDK\common\lib"

echo Linking ...

if exist %CUFILE%.exe del /f /q %CUFILE%.exe

link /nologo /out:%CUFILE%.exe %OBJ% %CUDALIBS% %LIBPATHS%

:EOF

endlocal

I should note that I developed this with the help of this forum topic on building with nvcc in Visual Studio.

Good luck!

Mike