Compilation fails after migration to CUDA 10.2

Hi,

I’ve been using VS2015 + CUDA 8.0 for a long time (since I had to support devices with 2.0 architecture), now I’m switching to VS2017 + CUDA 10.2 and can’t compile my files.

The error is: nvcc fatal : A single input file is required for a non-link phase when an outputfile is specified.

This happens due to incorrect parsing of the command line (the case which seemed to be handled correctly in CUDA 8.0): nested path with spaces is parsed incorrectly in the -Xcompiler switch.

It is very easy to reproduce:

  1. Create the NVIDIA CUDA test project via the project wizard.
  2. Rename the configuration the project is being built in from “Debug” to “Debug 123”.
  3. Try to compile the .cu file - the error occurs.

Here is the command line:
“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin\nvcc.exe”
-gencode=arch=compute_30,code="sm_30,compute_30"
–use-local-env
-ccbin “C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64”
-x cu
-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\include"
-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\include"
–keep-dir “x64\Debug 123”
-maxrregcount=0
–machine 64
–compile
-cudart static -DWIN32 -DWIN64 -D_DEBUG -D_CONSOLE -D_MBCS
-Xcompiler “/EHsc /W3 /nologo /Od /Fd"x64\Debug 123\vc141.pdb” /FS /Zi /RTC1 /MDd "
-o “x64\Debug 123\kernel.cu.obj”
“D:\zNoBackup\TestCuda\TestCuda\kernel.cu”

I have highlighted the line that seems to fail to be handled: nested quotes appear due to the path with spaces.

What to do about it? The answer “remove the spaces from paths” is obvious, however, the solution I’m working with is pretty big and I don’t want to modify it extensively.

Thank you.

If I correctly understand what you have written, the problem is the path for the intermediate directory has a space in it and it is causing a problem. I also read your note about the size of the solution.

I deal with this kind of thing constantly. I find VS2017’s UI for adjusting solution configurations to be woefully inadequate so I do always do that stuff by hand. In your case, this is a very simple thing you can fix with your text editor of choice. You could even do it with VS2017 if you want to. Load the solution’s .VCXPROJ file into the text editor and do a search and replace of “Debug 123” with Debug_123 and your problem will be fixed. This should take less than a minute for you to do and is the only modification necessary.

One thing I find helpful is to organize the project solution files in a way that facilitates use of multiple versions of the compiler. To do this I use a directory structure like this :
MySolution
±- Source
±- VS2015
±- VS2017
±- VS2019

and then each VS directory has their own intermediate directories below them. This way you don’t have to modify your solution, per se. You copy it to the VS2017 directory and adjust it for that version of the compiler. When/if you move to VS2019 then make a new VS2019 subdirectory, copy your solution to it, and adjust it for that version of the compiler. This way all your old solutions for the previous compilers are still there and usable.

This is one reason, among several, that I avoid using spaces in file names.

Thank you for the detailed reply!

The problem is a bit different, though: as I said, nested quotes are no longer parsed properly (CUDA 8.0 did that well).

Please, check this string out:
-Xcompiler “/EHsc /W3 /nologo /Od /Fd"x64\Debug 123\vc141.pdb” /FS /Zi /RTC1 /MDd "

This is the “quotes inside quotes” situation.

It goes without saying that it can be fixed by removing the sapces from folder names, however, technically, spaces in folder names are not prohibited, CUDA 8.0 hanled them flawlessly, however, CUDA 10.2 does not.

Have you tried escaping the inner quotes with a preceding backslash?

Christian

I have made it compilable via removing of spaces from dir names. The point is not in making it compilable though, the point is that CUDA 8.0 handled properly what CUDA 10.2 fails to handle.

@roman.tatkin Are you still experiencing this problem? I’m using CUDA 11.4 and CMake 3.21.3 and I have the same issue. In my project, VS is trying to run the following command, but nvcc complains that I have more than one input file, which I don’t:

"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4\bin\nvcc.exe"
-gencode=arch=compute_52,code=\"compute_52,compute_52\" 
-gencode=arch=compute_52,code=\"sm_52,compute_52\" 
--use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64" 
-x cu 
-rdc=true   
-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4\include"     
--keep-dir x64\Debug  
-maxrregcount=0  
--machine 64 
--compile 
-cudart static 
-std=c++14 
-Xcompiler="/EHsc -Zi -Ob0" 
-g  
-D_WINDOWS 
-D"CMAKE_INTDIR=\"Debug\"" 
-D_MBCS 
-DWIN32 
-D_WINDOWS 
-D"CMAKE_INTDIR=\"Debug\"" 
-Xcompiler "/EHsc /W3 /nologo /Od /Fd"C:\Users\<firstname lastname>\Documents\Github\code-samples\posts\cmake\build\Debug\particles.pdb" /FS /Zi /RTC1 /MDd /GR" 
-o particles.dir\Debug\particle.obj 
"C:\Users\<firstname lastname>\Documents\Github\code-samples\posts\cmake\particle.cu"

Have you tried escaping the inner quotes (after /Fd) in the last -Xcompiler switch with a backslash?

Have you tried escaping the inner quotes (after /Fd ) in the last -Xcompiler switch with a backslash?

@njuffa I tried that but it didn’t work.

I finally got it to work by moving the project to a folder with no spaces in the path name, which eliminated the need for quotation marks around the path to the .pdb file (after /Fd, like you said).

I’ve also filed a bug with CMake, found here: https://gitlab.kitware.com/cmake/cmake/-/issues/22786