CUDA 6.5 building problem

After I updated CUDA to 6.5 i can’t build any projects except Samples. When I try to build even simplest code I’m getting following error:

Error	2	error MSB3721: The command ""D:\Projects\CUDA\CUDA Toolkit\bin\nvcc.exe" -gencode=arch=compute_11,code=\"sm_11,compute_11\" -gencode=arch=compute_20,code=\"sm_20,compute_20\" -gencode=arch=compute_30,code=\"sm_30,compute_30\" -gencode=arch=compute_35,code=\"sm_35,compute_35\" -gencode=arch=compute_37,code=\"sm_37,compute_37\" -gencode=arch=compute_50,code=\"sm_50,compute_50\" -gencode=arch=compute_20,code=\"sm_20,compute_20\" --use-local-env --cl-version 2013 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin"  -I"D:\Projects\CUDA\CUDA Toolkit\include" -I"D:\Projects\CUDA\CUDA Toolkit\include" -I"D:\Projects\CUDA\CUDA Toolkit\include"  -G   --keep-dir Debug -maxrregcount=0  --machine 32 --compile -cudart static -Xcompiler "/wd 4819"  -g   -DWIN32 -DWIN32 -D_DEBUG -D_CONSOLE -D_LIB -D_UNICODE -DUNICODE -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MTd  " -o Debug\ "c:\Users\Łukasz\documents\visual studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\"" exited with code 255.	C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations\CUDA 6.5.targets	593	9	ConsoleApplication1

For whatever reason samples given with 6.5 toolkit work fine. I using VS2013. Previously i was using CUDA 6.0 and everything was working just fine. Problems started after update to 6.5.

Can anyone help me solve this issue? I need this working as soon as possible.
Thanks in advance.

Enable verbose output in VS, so you can see the actual error returned by nvcc, rather than just the error indicated by the executive in VS.

This is the output I got when I set output verbosity to detailed. There are some errors at the end but I don’t really know how to fix them.

After I installed Cuda 6.5 all i’ve really done is i copied contents of MSBuildExtensions folder that was in the package to MSBuild directory.

Here is link to output VS gives me when i build my project.

There are some errors at the end but I don’t know how to fix them.

"After I installed Cuda 6.5 all i’ve really done is i copied contents of MSBuildExtensions folder that was in the package to MSBuild directory. "

That shouldn’t be necessary. If VS 2013 is installed before CUDA 6.5, the CUDA installer should find it and make the necessary updates. You may have some unrecognized installation of VS2013. You might want to re-install VS2013 in a standard location, then re-install CUDA 6.5 and following the instructions in the windows getting started document that comes with CUDA 6.5.

I forgot to select the 6.5 build customisation, wasted 5 minutes banging head on wall…

I uninstalled toolkit and installed it again using default installation. It still doesn’t work. If i try to use Cuda template i get same error as mentioned above. If i create new empty project and setup it by myself output says and project is built but .exe file is not generated. If I create error compiler still says that project is build successfully


I made some progress. When I switched off (-G) option I’m able to build my code and code from visual studio template given by NVidia.

Problem is that I’d like to have -G switched on.

I am facing the similar problem. Have anyone came across working solution?

Many Thanks

I have the same problem with CUDA 6.5. Please help.

It occurs only with custom-made projects. Programs connected with CUDA Toolkit work fine.
When I turn off the ‘-G’ option the build succeedes.

Hello all, i face the same problem Error MSB3721 - exiting with code 255.

how to turn off the -G option ?


Recently I got the same compilation error “code 255” with CUDA 6.5 and VS 2013. The cause of this error appeared to be the difference between declaration and definition of one device function (both of which were in a single .cu file). The call of this function matched the declaration, while the definition had two less arguments.

-G option corresponds to “CUDA C/C++ \ Device \ Generate GPU Debug Information” option in Visual Studio.

Thanks alot for your answer. I had the same error & the solution was to relocate device functions to the file where the global or the calling function resides.

Thanks, that shaved a few hours of coding time for me as well. It is a tad silly that definitions of functions can be included in the standard .h file, but implementations with global/host/device keywords must be in the same .cu file. When they are in .cpp file, they do not get properly identified by the compiler and Error 255 is generated.

A file ending in .cpp is not processed by nvcc, by default. It is processed by the host compiler (cl.exe on windows) which knows nothing about CUDA syntax.

Any sort of CUDA-specific syntax, such as global, device, constant, etc. must be in a file processed by nvcc, to be useful. These things can be in a “standard” .h file, assuming that file only gets included in files processed by nvcc. But if you include such a file in a .cpp file, you’re asking for trouble. Because of this, some folks in the project organization create .cuh files, to designate a header file that should be included only in files processed by nvcc, since it contains (presumably) CUDA specific syntax.

In retrospect, it does make sense, but it leads to less coherent code, since now my class lives in .h/.cpp files in 98% and the rest was moved to the main .cu file to avoid creating separate set of header files.

I did not find any reference to this fact anywhere in documentation from NVidia - did I miss it?

I don’t know what fact you are referring to. That files ending in .cpp are not processed by nvcc?

Correct, and the fact that function implementations to be executed in the kernel must be part of the .cu file, even though they belong to a separate class.

Put it differently, an example of a class that has functions that can be executed on device and host alike would be helpful. There are plenty of people out there learning CUDA and helping people avoiding pitfalls is critical to the success of this platform. Some caveats have non-trivial solutions, and require digging through fora, since they are listed / mentioned in documentation in any way

Just my 2.5 cents, nothing more :)

file suffixes and the compiler default behavior associated with them are covered in the nvcc manual:

that is default behavior, it can be modified, there are documented switches in that manual to do so.

I’m not sure about the rest of what you are suggesting, for example this:

“function implementations to be executed in the kernel must be part of the .cu file”

Isn’t that just a restatement of the previous point? Assuming default behavior, device code (code that you want to execute on the device, decorated either with device or global) must be defined in a .cu file (or stated differently, must be processed by nvcc).

regarding this:
“an example of a class that has functions that can be executed on device and host alike would be helpful.”

functions that can be executed both on the host and the device are those functions that are decorated with host device

It’s easy to have class member functions that are decorated that way, and the implementation can be defined anywhere, just as you would expect for an ordinary class, except that where ever you defined the implementation, that file has to be processed by nvcc (normally, it would in or included in a .cu file).

There are plenty of examples of such functions and classes in the CUDA sample codes, if you care to look.

I also have this error, exited with code 255. I have only one .cu file with CUDA8.0 and VS2015, but still have this error. Please help. Thanks.

ptxas fatal : Unresolved extern function ‘cublasCreate_v2’
1>CUDACOMPILE : nvcc warning : The ‘compute_20’, ‘sm_20’, and ‘sm_21’ architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\BuildCustomizations\CUDA 8.0.targets(689,9): error MSB3721: The command ““C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin\nvcc.exe” -gencode=arch=compute_20,code=“sm_20,compute_20” --use-local-env --cl-version 2015 -ccbin “D:\Microsoft Visual Studio\2015\VC\bin\x86_amd64” -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include” -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include" --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -g -DWIN32 -DWIN64 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler “/EHsc /W3 /nologo /Od /FS /Zi /RTC1 /MDd " -o x64\Debug\ “F:\CUDA_code\test\inverse_device\inverse_device\”” exited with code 255.

but I already #include <cublas_v2.h> and #pragma comment(lib, “cublas.lib”).
In the code, in global function, cublas function is called.

You have to add the CUDA CUBLAS library to your VS project.

You also have to add the CUBLAS device library to your project.

You also need to adjust your project to compile for an architecture which supports device cublas, which is cc3.5 or higher.

For the above items, the simplest instruction is probably just to study a cuda sample code project which fits this description, such as simpleDevLibCUBLAS. Note that the device-callable CUBLAS capability is deprecated and/or removed in newer CUDA versions, so you won’t be able to maintain that code using the latest CUBLAS versions.