Sunday, February 17, 2013

How to make a new CUDA project in VS 2012

this post is an update for How to make a new CUDA project in VS 2010 but this time for 2012

I'm using Windows 8 64-bit with Microsoft Visual Studio 2012, and Nvidia CUDA 5.0

first you must do these steps once:

1- copy files "CUDA 5.0.props, CUDA 5.0.targets, CUDA 5.0.xml, and Nvda.Build.CudaTasks.v5.0.dll" to:
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations

2- copy "host_config.h" and replace the one in:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include

3- copy "usertype.dat" from:
C:\ProgramData\NVIDIA Corporation\CUDA Samples\v5.0\doc\syntax_highlighting\visual_studio_8
to:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE

4- in Visual Studio 2012 IDE Select Tools menu -> Options -> Text Editor -> File Extension
type "cu" under Extension and select "Microsoft Visual C++" from Editor list and click Add

then these steps are for creating a new project:

1- create a New Project -> C++ Win32 Console Application -> Empty Project

2- mark the project in the Solution Explorer, then select Project menu -> Build Customizations -> CUDA 5.0 or whatever version you're using

3- right click the project in the Solution Explorer and select Properties

4- select VC++ Directories and add to Include Directories:
$(CUDA_INC_PATH)

5- select Linker -> General and add to Additional Library Directories:
$(CUDA_PATH)/lib/$(PlatformName)

6- select Linker -> Input and add to Additional Dependencies:
cudart.lib

7- now add your .cu file

hint: include 
#include "cuda.h"
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
because Visual Studio will give you error for some CUDA keywords but will compile fine

your comments are welcomed

special thanks to Angga Reza Fardana for modifying the files and to Ade Miller too