cannot find cuda.h

Hello,

I’m trying to write a simple matrix addition CUDA program in VS2005 on WinXP and, the compiler complains that it cannot find the cuda header file (complainat the line #include <cuda.h>). here are my program files in a VS solution:

matrixAdd.cu:

#include <cuda.h>

global
void add_matrix( float* a, float *b, float c, int N )
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDim.y + threadIdx.y;
int index = i + j
N;
if ( i < N && j < N )
c[index] = a[index] + b[index];
}

matrixAdd.cpp

#include <cuda.h>
int main() {
float a = new float[NN];
float b = new float[NN];
float c = new float[NN];
for ( int i = 0; i < N*N; ++i ) {
a[i] = 1.0f; b[i] = 3.5f; }
float ad, bd, cd;
const int size = N
N
sizeof(float);
cudaMalloc( (void
*)&ad, size );
cudaMalloc( (void**)&bd, size );
cudaMalloc( (void**)&cd, size );
cudaMemcpy( ad, a, size, cudaMemcpyHostToDevice );
cudaMemcpy( bd, b, size, cudaMemcpyHostToDevice );
dim3 dimBlock( blocksize, blocksize );
dim3 dimGrid( N/dimBlock.x, N/dimBlock.y );
add_matrix<<<dimGrid, dimBlock>>>( ad, bd, cd, N );
cudaMemcpy( c, cd, size, cudaMemcpyDeviceToHost );
cudaFree( ad ); cudaFree( bd ); cudaFree( cd );
delete a; delete b; delete c;
return EXIT_SUCCESS;
}

Anyone know what’s the problem and what’s the solution?

Many thanks.

is it required to compile your program?
try to comment the line and launch the compiler alike…

You don’t need cuda.h. You need to compile using nvcc instead of vc++. Look at the SDK samples. They use a ‘custom build step’ for each cuda file that invokes nvcc. Nvcc puts in all the headers and definitions a cuda program needs.