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.