1. 在NVIDIA的CUDA首页上下载toolkit和driver并安装
http://www.nvidia.com/object/cuda_develop.html
装好Toolkit以后,以下几个环境变量会自动配好:CUDA_BIN_PATH, CUDA_INC_PATH, UDA_LIB_PATH
2. 新建project
选择一个empty project,在resource里添加myfirstcuda.cu
3. 编辑编译/连接属性
CUDA的编译工具是nvcc,这里需要用custom build tool 中设定一下:
1)在刚创建的myfirstcuda.cu上右键,properties
2)在general项里,选定tool中为custom build tool
3)选择Custom Build Step, ,
Release中,将Command Line改为:
" $(CUDA_BIN_PATH) /nvcc.exe " - ccbin " $(VCInstallDir)bin " - c - DWIN32 - D_CONSOLE - D_MBCS - Xcompiler / EHsc, / W3, / nologo, / Wp64, / O2, / Zi, / MT - I " $(CUDA_INC_PATH) " - o $(ConfigurationName)/$(InputName).obj $(InputFileName)
![]()
Debug中,将Command Line改为:
" $(CUDA_BIN_PATH) vcc.exe " - ccbin " $(VCInstallDir)bin " - c - D_DEBUG - DWIN32 - D_CONSOLE - D_MBCS - Xcompiler / EHsc, / W3, / nologo, / Wp64, / Od, / Zi, / RTC1, / MTd - I " $(CUDA_INC_PATH) " - o $(ConfigurationName)/$(InputName).obj $(InputFileName)
All Configuration中,将Output改为:
$(ConfigurationName)/$(InputName).obj
4)选择Propject - properties, configuration properties, linker
修改以下configuration
General : Enable Incremental Linking : No ( / INCREMENTAL:NO)
General : Additional Library Directories : $(CUDA_LIB_PATH)
Input : Additional Dependencies : cudart.lib
4. 写个程序试试,就可以在VS2005里build了