Monday, April 13, 2009

Setting up CUDA project

Any developer sooner or later returns to 'first high level language' - C. Java developer with realy great IDEs or very dynamic Rubyist may be confused with all that 'old' stuff. Linux kernel developer will ask why he need an IDE if there is vim or emacs editors =)

When starting developing with new framework, we always spend some time especially on Windows to setup appropriate paths, tools etc.

So I've decided to write down some check list to setup Visual Studio 2008 express edition to develop with CUDA.

1. Download and install Visual Studio Express 2008 for C++. From here:

2. Install latest drivers from NVidia. From here:

3. Download and install Cuda Toolkit and CUDA SDK. From here:

4. Set CUDA_INC_PATH,CUDA_LIB_PATH in windows environment variables

5. Copy project folder to $CUDA_SDK_HOME\projects\

6. Use instructions from $CUDA_SDK_HOME\doc\syntax_highlighting to enable syntax highlighting for .cu files

7. cppIntegration project from CUDA SDK have very helpful build rules for .cu file. So just add additional xml sections to you .vcproj file. Don't know if there is standard way to do this, so I've done this by hand.
Add ToolFile to ToolFiles section:
<ToolFiles> <ToolFile RelativePath="..\..\common\Cuda.rules" /> </ToolFiles>

Add additional build rule to all of your Configurations:

<Tool Name="CUDA Build Rule" Include="$(CUDA_INC_PATH);$(CUDA_SDK_INC)" />

After that from properties of .cu file you can tell Visual studio to build that file with nvcc just by specifying build rule as 'CUDA Build Rule"

Go GPU, Go!