Setting up CUDA on Visual Studio 2010

Hello,
I have been having a heck of a time setting up CUDA to compile on VS 2010. So far I have checked CUDA 4.2 in the build configurations and written a few short functions to test.

In the kernel.cu file I have:

[font=“Arial Black”]#include “kernel.h”
#include <cuda.h>
#include <cuda_runtime_api.h> // includes cuda.h and cuda_runtime_api.h
device int kernel(void){
return 5;
}
int call(){
return kernel<<<1,1>>>();
}[/font]

In kernel.h, I have:

[font=“Arial Black”]#ifndef KERNEL_h
#define KERNEL_h
int call();
#endif[/font]

And in main.c, I have:

[font=“Arial Black”]#include “kernel.h”
#include <cuda.h>
#include <cuda_runtime_api.h>
int main() {
call();
}[/font]

The problem is that the triple brackets register errors even in the .cu file. Also, cudaMalloc is not recognized in call(). Is there anything I need to do besides the build configurations to get this to work? Thank you.

Yeah just went through the same preocess recently :-)

I’m assuming you’ve already addedd the CUDA 4.2 .target file in build customization but make sure you have also setup:

include directory:

Properties --> CUDA C/C++ --> common --> Additional include directories , add : $(CUDA_PATH)/include

LIB:

Properties --> Linker --> Additional LIbrary directories --> add : $(CUDA_PATH)/lib/x64 (or win32)

–> Linker --> input --> Additional dependencies --> add : cudart.lib

Optionally you may also:

–> Properties --> VC++ directores --> include diretories --> add $(CUDA_PATH)/include ( This mainly helps intellisense I think… )

Hope this is in anyway helpful!

Sorry for the super late response. Thanks a lot for the help! It has been really frustrating getting CUDA set up on VS 2010, but I think, after that, I finally got it.