Setting up Visual Studio Professional 2013 with CUDA 7.0 and running some examples

I started to learn programming CUDA with the book “CUDA by example”. The book is accompanied with some examples (source code: https://developer.nvidia.com/content/cuda-example-introduction-general-purpose-gpu-programming-0).

I’ve downloaded and installed the CUDA 7.0.28 version for windows which is compatible with my Visual Studio Professional 2013.

Next I’ve set up Visual Studio by

  • Tools -> Options -> Project and Solutions -> VC++ Project Settings -> Extensions to Include -> I added “.cu” in order to treat a .cu extension similarly as a .cpp extension
  • Tools –> Options -> Text Editor -> File Extension -> I added “cu” as Extension and "Visual C++" as Editor in order to enable some standard C++ keyword/syntax highlighting

On the web, I’ve found that there is some “usertype.dat” file included in earlier versions in order to enable some CUDA specific keyword/syntax highlighting. The file appears to be located in different directories depending on the version. Unfortunately none of these directories exist for my CUDA 7.0 version.

Next, I configured the NVIDIA Nsight Monitor by General -> Security -> Enable secure connection -> “True”

In order to run a single sample, I’ve created a New Project by selecting NVIDIA -> CUDA 7.0 -> CUDA 7.0 Runtime. Next I’ve configured the project by

  • Project -> Properties -> Configuration Properties -> VC++ Directories -> Include Directories -> I added "$(CUDA_INC_PATH)"
  • Project -> Properties -> Configuration Properties -> CUDA C/C++ -> CUDA Toolkit Custom Dir -> I added "$(CUDA_INC_PATH)"

In the past I only worked with some C++ projects for which a Solution file was available. So I’m not really sure where I have to put all the auxiliary files and folders. I’ve just placed the bin, lib and common folders inside my Project and included all the .dll, .lib and .h files in the project via the Solution Explorer. I only needed to change my #includes from “…/common/book.h” to “…/Test/common/book.h”.

So far I seem to be able to run the most easiest samples such as “add_loop_gpu.cu”. IntelliSense however shows an enormous list of errors like:

  • identifier "ULONG" is undefined
  • identifier "PCHAR" is undefined
  • cudaFree, cudaSuccess, ... is undefined

When I add these includes
#include “cuda.h”
#include “cuda_runtime.h”
#include “device_launch_parameters.h”
in my header file, IntelliSense stops complaining. Except for the add<<<N,1>>>( dev_a, dev_b, dev_c ) calls, because I guess this is some CUDA specific syntax not present in C++.

Now my problem appears with the “julia_gpu.cu” example. Due to some errors which make sense, I fixed the example by adding the “device” keyword before the “cuComplex” constructor because this method is called from other device methods. After this fix, IntelliSense only has a problem with the <<< (again).
After running with the Local Windows Debugger, I receive:

“The application was unable to start correctly (0xc000007b)” due to an unhandled exception at 0x7765D4F2 (ntdll.dll) in Test.Exe: 0xC000007B: %hs is either not designed to run on Windows or it contains an error.

What does this mean (ntdll.dll is located at C:\Windows\SysWOW64\ntdll.dll)?

I also followed this approach:
http://stackoverflow.com/questions/14745652/julia-set-cuda-by-example-help-me-set-up-the-project
I also used the cpu instead of gpu version

But in both cases the problem remains

The solution http://stackoverflow.com/questions/32314639/setting-up-visual-studio-professional-2013-with-cuda-7-0-and-running-some-exampl/32326988#32326988 can be found here. The problem was purely Linker related.