Neither Terminal or VS17 compiling

I’m very new to CUDA, and just installed Visual Studio 17 community and the CUDA toolkit on my windows 10 machine, that runs a Nvidia Geforce GTX 1060 GPU. So far i have managed to run code sample solutions directly in VS 2017, but only samples.

I have a piece of CUDA accelerated cpp code from my colleague that he compiles and runs on a regular basis on his unix based system. If i open a new project in VS17 and replace the kernel.cu with my code, this won’t build. Neither can i seem to compile sample files from either the system terminal or the VS dev terminal, getting the same errors in both prompts.

I have manually added bin, include and lib to my path to get around the “cl.exe not in path” error that I got in the start in the system terminal, and when running sample codes i get “fatal error C1083: Cannot open include file: ‘helper_cuda.h’: No such file or directory”, whilst my colleagues code returns

nvcc RWcuda2.cu
RWcuda2.cu
RWcuda2.cu(121): error: expression must have a constant value
RWcuda2.cu(121): note: the value of variable "Tsub"
(119): here cannot be used as a constant

1 error detected in the compilation of "C:/Users/<user>~1/AppData/Local/Temp/tmpxft_00004d0c_00000000-12_RWcuda2.cpp1.ii".

but a whole different set of errors when building from VS17, all of the above which leads me to believe the code isn’t the issue here.

I am calling the code by

nvcc <programname>.cu

in the terminal, and in VS17 i’ve tried to use the build option. I have also tried both reinstalling VS17 and reinstalling the CUDA toolkit several times. Hope you might be able to help me out.

The helper_cuda.h issue is because you haven’t included the path to it. It isn’t the same path as the ordinary CUDA include path.

The problem with RWcuda2.cu looks like a problem with the code at line 121 or line 119, just as the compiler is telling you.

I figured that there were errors in the code, but is it likely that there would be errors compiling and running fine on a Unix based system but not in windows? (Sorry, i’m not super experienced as a programmer yet, just a student)

Also, could you point me to what i need to include in my path variable other than bin, lib and include? I don’t think i read this in the toolkit documentation.

Thanks in advance.

Rather than have someone tell you a path, its better for you to learn how to do these things yourself.

  1. Use an appropriate utility on windows to find the header file you want to include. The utility will give you the path to the file. The windows file explorer can locate the file (helper_cuda.h) for you.

  2. Add that path to the include directory list in your VS project.