Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include <cuda_runtime.h> in .cpp file

I have problem to include <cuda_runtime.h> in .cpp file. Error: Cannot include file: cuda_runtime.h: No such file or directory.

I am trying to complie code from Rob Farber ( http://www.drdobbs.com/architecture-and-design/222600097?pgno=1 ).

I have compiled few cuda codes before but <cuda_runtime.h> was allways included in .cu file.

I am using VS 2008 Express.

Q: Do I have to link VS somehow different so it knows where to look for <cuda_runtime.h>?

like image 871
user1281071 Avatar asked May 16 '12 10:05

user1281071


2 Answers

In Visual Studio 2008, add the path of the include files in Visual C++ directories.

"Installation Path"\NVIDIA GPU Computing Toolkit\CUDA\"version"\include\

Here is the procedure:

In Visual Studio 2008, go to
- Tools -> Options -> Projects And Solutions -> Visual C++ Directories.
- Select include files from the drop down list named "Show Directories For".
- Add new item by clicking the yellow button below the drop down list.
- Paste the include fles path here.
- Verify the correctness of path by clicking the check button on left of yellow button
- Click ok and restart visual studio.

Now Visual Studio 2008 will know where the include file is located.

like image 91
sgarizvi Avatar answered Sep 29 '22 06:09

sgarizvi


Instead of setting up a hard-coded path - which you will most likely have when locating CUDA installation on your machine - you can also add cudart.lib as additional dependency for the linker.

Right click on the project > Properties > Linker > Input > Additional Dependencies. Add cudart.lib there.

like image 34
Peter Merkert Avatar answered Sep 29 '22 05:09

Peter Merkert