CUDA 6.5 nvcc building invalid cl.exe command line with extra double quotes

I just installed 6.5, the latest nvidia driver for my GTX 970, and VS2013 Community Edition. I had python 2.7.8 already installed. I am new to CUDA and VS2013 development but not python. I can mostly build and run some of the CUDA VS2013 sample solutions so things work up to that point. I say mostly only because some solutions, bandwidthTest for example, builds fine as x86 but nvcc errors when I change it to x64. Since other solutions build and run as x64, I haven’t spent time to investigate.

Now I’m trying to verify my pyCUDA install by running a small test python program. After troubleshooting to get the needed nvcc flags for pyCUDA, the following nvcc command gets built and executed by my test program:

nvcc -cubin -keep -ccbin B:\VisualStudioCom2013\VC\bin\amd64 -cudart shared -arch sm_52 -m64 -IB:\anaconda2\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg\pycuda\cuda

Python spawns the above command in a subprocess and nvcc starts to do its thing. Then this error pops up:

CompileError: nvcc compilation of e:\temp\cb4\tmpdx3stw\ failed

and this error is returned from the subprocess to my program via stderr:

'B:\VisualStudioCom2013\VC\bin\amd64"\cl.exe @kernel.cpp1.ii.res > "kernel.cpp1.ii' is not recognized as an internal or external command, operable program or batch file.

Note the extraneous double quotes. They look like they’ve been inserted in the same way a Windows path that has spaces in it has to be quoted. Regardless, they are causing the error. Without them I can manually run B:\VisualStudioCom2013\VC\bin\amd64\cl.exe @kernel.cpp1.ii.res > kernel.cpp1.ii and it completes just fine i.e. a valid kernel.cpp1.ii is generated without error. I’ve gone as far as I can go in the python code, verifying that the above nvcc command is correctly getting passed to CreateProcess(). As a newbie CUDA developer, I hate to jump to the “it’s an nvcc bug” conclusion. Any ideas?


is there a python forum you could ask?

@cb4, try adding “C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC” to your path and run the VS2013 “vcvarsall.bat” batch file once before you start using NVCC from the command line. You can then drop the -ccbin switch.

Alternatively, if you’re working from a command shell inside of an editor like Emacs on Windows then create a custom shortcut to the vcvarsall.bat batch file and Emacs like so:

"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86_amd64 && "C:\Program Files (x86)\emacs-24.3\bin\runemacs.exe"

This ‘&&’ trick is generally useful for any shell or application that needs access to the VS command-line environment.

@wlangdon, this is not a python problem. Python has already passed control to nvcc running in a subprocess and is not responsible for creating the cl.exe command line. It is only reporting the results of the nvcc run.

@allanmac, thanks for the tip.

This appears to be a bug in nvcc. By eliminating all other command line options and profile settings, I narrowed the problem down to this: when compiler-bindir is set in nvcc.profile AND the --keep (or -keep) option is used on the command line, the malformed cl.exe command with double quotes is generated. The solution for keeping intermediate files is to make sure cl.exe is in the path and remove compile-bindir from nvcc.profile.

Fixed in CUDA Toolkit 7.0 and higher.