I spent an age trying to set up with CUDA. When I finally figured out how, I decided that I never wanted to have to go through that again and wanted to write a tutorial for me and others just in case I need to do it again in the future.
What you need:
You cannot get this done in 64bit express for various reasons but can in the paid for 64 bit version. I do not cover 64bit, I just hope that its the same which it probably isnt.
If your not running windows, or are wanting 64 bit nvidia toolkit get it from the relative section from this site.
Again if your wanting the 64bit Nvidia SDK then click the necessary option from the bottom of the largest post on this page (you'll know when you see it):
Lastly follow these steps to set up MSVC++ 2008. These steps were taken from here. (looks harder than it is).
Step 1: Adding cuda.rules to your project
Right click on your project –> Custom Build Rules
Click on New Rule File and browse to your %CUDA Folder%cuda_build_rule/cuda.rules
Step 2: Now setup your BIN, INCLUDE and LIB directories.
Goto Tools –> Options –> Projects and Solutions –> VC++ Directories
First, lets specify the INCLUDE directories. Select Include Directories from the “Show Directories for” dropdown menu.
Create a new line by clicking the new file button and specify %CUDA Directory%include
Similarly, select Library files from the dropdown and specify: %CUDA%lib directory
Similarly, select Executable files from the dropdown and specify: %CUDA%bin directory
Final Step: Specify the CUDA Runtime and CUTIL32D Linkers
Linkers work during compilation when your code is linked to external libraries that you use.
Goto Project –> Properties –> Configuration Properties –> Linker –> Input and specify two few files in the Additional Dependencies field: CUDART.lib and CUTIL32D.lib
Now goto Project –> Properties –> Configuration Properties –> Linker –> General and paste this line in the Additional Library Directories field: $(CUDA_LIB_PATH);../../common/lib
Alas! You’re done! Now you can try Rebuilding the sample code that comes with CUDA SDK. Simply open the project folder and then open the .sln file in it to open it in VS08 and then Right click on the project and click Rebuild and run it for yourself!
If everything has been properly setup, The Rebuild should be Successful.
Please note that when the site explaining how to set up the IDE is asking you to link the SDK library and include files etc, you should go here on your computer:
C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK\C
and ALSO here just to be safe:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA.
I couldnt get it to work just linking one of either, I dont know what to mix and match so i just linked all lib / bin/ and inc folders from both areas and works.
Also note that any cuda programming you do should have the file extension '.cu' and not '.c' or '.cpp' just in case you didn't know. Seems like nobody ever mentions the more obvious stuff. Note that the single quote marks are not to be part of the file name.
No comments:
Post a Comment