CUDA build error

Hello all,
I am new to CUDA. I am trying to run my first CUDA code.
This is what I have:

  1. I use VS2015 and I have installed the CUDA SDK.

  2. I included the following include and library directories in VS project settings:
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64

  3. In build customization, I have ticked ‘CUDA 8.0(.targets,.props)’

When I build a simple code I get:
Syntax error: ‘<’.

This is coming from the kernel call: Square<<<1,64>>>(d_out,d_in);


Provide the full error output from VS. What is the filename of the file you are compiling?

Also, this may not be actually a build error but an intellisense error.

The file name is CudaTest.cpp.
Does it have to be ?

The error (Build Only):
C2059 syntax error: ‘<’

It is coming from

yes it should be .cu

take a look at any of the cuda sample projects

I changed it to .cu. I am still getting the same error.

You need to not just change the file extension to .cu but you have to create a new CUDA C/C++ source module in your VS project. When you do that, it will automatically have a file extension of .cu and it will use nvcc to compile.

To repeat my suggestion again, take a look at any of the cuda sample projects.

Thanks!. That worked.