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.
"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 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
EDIT:
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.
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?
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
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 hostdevice
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.
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.