2

I am trying to compile CUDA code from the command line using CUDA toolkit version 5.0 and the Visual Studio 2010 Professional compiler. In response to the following,

nvcc -c AddVectors.cu -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin"

I get the following error message

nvcc : fatal error : Visual Studio configuration file '(null)' could not be found for installation at 'C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin/../..'

I also get this error message when Rebuilding within the VS 2010 IDE, but not when I just plain Build.

I am by no means a Visual Studio expert, but what is curious about the error message for me is that nvcc seems to exit the compiler directory I have specified and search upward from there VC/bin/../.. Why is it doing this? Why does it need anything other than the compiler executable in VC/bin/ and what is the role of the "Visual Studio configuration file" in all of this?

And, last but not least, how do I resolve this?

EDIT: My environment and search path are

ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\mjacobson\AppData\Roaming
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=WAA04087-RD
ComSpec=C:\Windows\system32\cmd.exe
CUDA_BIN_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin
CUDA_INC_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include
CUDA_LIB_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\lib\x64
CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\
CUDA_PATH_V4_2=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\
CUDA_PATH_V5_0=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\
C_IA64_REDIST11=C:\Program Files (x86)\Common Files\Intel\Shared Files\cpp\
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Users\mjacobson
LOCALAPPDATA=C:\Users\mjacobson\AppData\Local
LOGONSERVER=\\SVRAABKP01
NUMBER_OF_PROCESSORS=12
NVCUDASAMPLES5_0_ROOT=C:\ProgramData\NVIDIA Corporation\CUDA Samples\v5.0\
NVCUDASAMPLES_ROOT=C:\ProgramData\NVIDIA Corporation\CUDA Samples\v5.0\
NVTOOLSEXT_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\nvToolsExt\
OS=Windows_NT
Path=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin\;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\libnvvp\;C:\Program Files (x
86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Common Files\Intel\Shared Files\cpp\bin\ia64;C:\Program Files\AccelerEyes\Jacket\engine\bin
64;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\ATI Technologies\ATI.ACE
\Core-Static;C:\Program Files (x86)\NTRU Cryptosystems\NTRU TCG Software Stack\bin\;C:\Program Files\NTRU Cryptosystems\NTRU TCG Software Stack\bin\;C
:\Program Files\Wave Systems Corp\Gemalto\Access Client\v5\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common
Files\Roxio Shared\10.0\DLLShared\;C:\Program Files\MATLAB\R2013b\runtime\win64;C:\Program Files\MATLAB\R2013b\bin;C:\Program Files\MATLAB\R2012b\runt
ime\win64;C:\Program Files\MATLAB\R2012b\bin;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\Program Files (x86)\Common Files\Xoran Technol
ogies;C:\Program Files\MATLAB\MATLAB Compiler Runtime\v81\runtime\win64;C:\Program Files\MATLAB\R2011b\runtime\win64;C:\Program Files\MATLAB\R2011b\bi
n;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Ser
ver\100\DTS\Binn\
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 44 Stepping 2, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=2c02
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC=C:\Users\Public
RoxioCentral=C:\Program Files (x86)\Common Files\Roxio Shared\10.0\Roxio Central36\
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\MJACOB~1\AppData\Local\Temp
TMP=C:\Users\MJACOB~1\AppData\Local\Temp

USERNAME=mjacobson
USERPROFILE=C:\Users\mjacobson
VS100COMNTOOLS=c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\
windir=C:\Windows
Matt J
  • 1,127
  • 7
  • 15
  • This is the third time you ask the same question on SO and in this way it don't work - previous [here](http://stackoverflow.com/questions/21103243/compiling-cuda-code-from-the-command-line) or [here](http://stackoverflow.com/questions/21076966/are-there-versions-of-the-cuda-toolkit-compatible-with-vs2010-express-64-bit). As you still got problems and as in a comment by @JackOLantern was said, that it shouldn't be possible with the express edition, why you won't give gcc a try. For example you can install it from [MinGw](http://www.mingw.org/). – hubs Jan 22 '14 at 20:11
  • No, it is a different question in many respects. In the other posts you cite, I was working with the Express version and only Visual C++ rather than a full installation of Visual Studio. Now, (as I mentioned) I am working with the Pro edition. Moreover, I have a full installation of Visual Studio, not just C++. Finally, the error message is a different one from what I reported in those other posts. – Matt J Jan 22 '14 at 20:57
  • @hubs It appears from the post above that the OP seems to be working with the Professional Edition now. – Vitality Jan 22 '14 at 20:57
  • @MattJ Take a look at this post [CUDA linking error - Visual Express 2008 - nvcc fatal due to (null) configuration file](http://stackoverflow.com/questions/2970493/cuda-linking-error-visual-express-2008-nvcc-fatal-due-to-null-configuratio). Although the question was asked for Visual Studio 2008, the answer by Amitabh Mritunjai was given for Visual Studio 2010. Also [How can I setup nvcc to use Visual C++ Express 2010 x64 from Windows SDK 7.1?](http://stackoverflow.com/questions/8900617/how-can-i-setup-nvcc-to-use-visual-c-express-2010-x64-from-windows-sdk-7-1) could be useful. – Vitality Jan 22 '14 at 21:01
  • @MattJ You appear to have something wrong with the environmental variables. I had the same issue much time ago and I remember that I have followed the same procedure by Amitabh Mritunjai, although with some variations. – Vitality Jan 22 '14 at 21:08
  • @JackOLantern, I have seen these posts, but it is just not clear to me how to adapt it to my platform. In particular, I have at least 3 versions of cl.exe in 3 different places, one in VC/bin, one in VC/bin/amd64, and one in VC/bin/ia64. In those other posts, the amd64 directory seems to be the relevant one, but how do I know which one is relevant to me? Also, those other posts recommend creating a vcvars64.bat function, but put them in very different places. I just had a better idea what I'm tampering with here, so I can decide which one is more applicable... – Matt J Jan 22 '14 at 21:21
  • Could you add the environment variables including search path to your question? – Roger Dahl Jan 22 '14 at 22:17
  • Usually this means you have a 64 bit CUDA toolchain and a 32 bit compiler. Try specifying a 32 bit built within the IDE, and adding `-m32` as an option to the nvcc command from the command line. – talonmies Jan 23 '14 at 08:00
  • @talonmies, That did help! The compilation ran successfully with the addition of -m32. However, I am trying to compile for 64 bit. Shouldn't I have a 64-bit compiler somewhere? I've installed Visual Studio within 64-bit Windows 7. How do I find my 64-bit compiler, and how do I make make nvcc see it? – Matt J Jan 23 '14 at 18:54
  • No further advice to offer, anyone? talonmies got me half way there! – Matt J Jan 24 '14 at 21:45

1 Answers1

5

CUDA nvcc is just a steering compilation driver, that means nvcc uses both MSVC compiler and the CUDA compiler to perform his actions.

In a Windows environment you need to pay attention to several things before starting the compilation, make sure to review all of these:

  • Make sure you have enough privileges to run/write compilation chain programs into your paths. If you're admin on a home personal computer, in order to debug your problem, make sure to run all of the below commands and programs with administrative privileges (if that solves the issue, it was it!)

  • Environment variables are used to set the appropriate compiler and toolkit paths besides drivers locations. Assuming a clean and fully functional installation of both CUDA 5.0 toolkit and MSVC2010 Pro, in order to compile your 64-bit CUDA code with the x64 version of MSVC2010 the best way to set everything up properly is to run the Visual Studio x64 Command Prompt. You can find this into the start menu Visual Studio 2010/Tools/Visual Studio x64 Command Prompt (I suppose also a cross-platform x64 could work for this). Remember to run it with administrative privileges (Amministratore == Administrator in my birth-language in the screen below)

enter image description here

Notice in the above screenshot the "Setting environment.." line: that makes sure all of the appropriate environment variables relative to the x64 version of the MSVC compiler. From the log you posted nvcc should be immediately found and be able to detect the compiler you're supplying to it.

  • Programs which frown upon executables calling other executables whose work files are inside administrative-righted folders might need to be dealt with: in simple terms anti-viruses defenders (e.g. Comodo) and active protections filters may prevent nvcc and the tools it uses from getting their work done, make sure to disable these if you encounter warnings / problems while debugging your issue.

Just to be clear about something else: VC/bin is the x86 version of the MSVC compiler, VC/x64 is the one you're interested in (also often referred as amd64), VC/ia64 is for the IA64 architecture (a proper 64 bit architecture, x64 systems are just x86 systems "rendered" 64 bit.. they weren't born 64 bit).

When compiling your project from the MSVC IDE make sure of the admin privileges, no active protection programs on and that you're either properly matching the x64 project type with the CUDA C/C++ architecture targeted

enter image description here

Make sure there are no mismatches in both the project properties and single .cu files properties. Make sure that (with a verbose output active) there's no -m32 flag when compiling stuff in a 64 bit project (or at least if you know what you're doing).

Marco A.
  • 43,032
  • 26
  • 132
  • 246
  • Wait, this means that in order to compile a project with CUDA, you **need** admin rights? – Ander Biguri Jul 07 '15 at 09:16
  • If everything is set up correctly (e.g. a laboratory pc where things have been properly installed and ACL'd by the administrator) it shouldn't be necessary. – Marco A. Jul 07 '15 at 10:08
  • Aaahhh but who has an admin that installs everything right in the first place? Good to know anyways – Ander Biguri Jul 07 '15 at 10:11