轉載自http://soft.zdnet.com.cn/software_zone/2009/1127/1527418.shtml
1、軟件需求:
cudadriver_2.3_winvista_64_190.38_general
cudatoolkit_2.3_win_64
cudasdk_2.3_win_64
VS2008
安裝前將之前安裝的sdk、toolkit、driver等卸載,再依次安裝上述軟件。如果開發平臺沒有支持CUDA的顯卡,則不需要安裝cudadriver_2.3_winvista_64_190.38_general。
2、 安裝檢查
在cmd下執行nvcc –V可以查看當前版本號
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2009 NVIDIA Corporation
Built on Mon_Aug__3_19:43:55_PDT_2009
Cuda compilation tools, release 2.3, V0.2.1221
執行bandwidthtest查看配置是否正常
進入ProgramDataNVIDIA CorporationNVIDIA GPU Computing SDKCbinwin64Release>目錄,執行
.bandwidthTest.exe --memory=pinned --mode=range --start=10240000 --end=10240000 -increment=10240000
若正常會有類似信息
Running on......
device 0:Quadro FX 580
Range Mode
Host to Device Bandwidth for Pinned memory
Transfer Size (Bytes) Bandwidth(MB/s)
10240000 5101.1
Range Mode
Device to Host Bandwidth for Pinned memory
Transfer Size (Bytes) Bandwidth(MB/s)
10240000 4650.8
Range Mode
Device to Device Bandwidth
Transfer Size (Bytes) Bandwidth(MB/s)
10240000 14812.5
&&&& Test PASSED
Press ENTER to exit...
執行deviceQuery.exe查看顯卡具體型號
. deviceQuery.exe
若正常會有類似信息
CUDA Device Query (Runtime API) version (CUDART static linking)
There is 1 device supporting CUDA
Device 0: "Quadro FX 580"
CUDA Driver Version: 2.30
CUDA Runtime Version: 2.30
CUDA Capability Major revision number: 1
CUDA Capability Minor revision number: 1
Total amount of global memory: 536870912 bytes
Number of multiprocessors: 4
Number of cores: 32
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 16384 bytes
Total number of registers available per block: 8192
Warp size: 32
Maximum number of threads per block: 512
Maximum sizes of each dimension of a block: 512 x 512 x 64
Maximum sizes of each dimension of a grid: 65535 x 65535 x 1
Maximum memory pitch: 262144 bytes
Texture alignment: 256 bytes
Clock rate: 1.13 GHz
Concurrent copy and execution: Yes
Run time limit on kernels: No
Integrated: No
Support host page-locked memory mapping: No
Compute mode: Default (multiple host threads can use this device simultaneously)
Test PASSED
Press ENTER to exit...
根據信息可以推算顯卡的單精度浮點處理性能爲3*32*1.13=108.48Gflops
3、 設置系統環境變量
將安裝的CUDA的sdk的路徑加到系統環境變量中:
例如C:ProgramDataNVIDIA CorporationNVIDIA GPU Computing SDKCbinwin64
下的
├─Debug
├─EmuDebug
└─EmuRelease
└─Release
幾個目錄都加入到系統環境變量PATH中,這樣才能在運行程序的時候找到相應的dll庫。(做法:添加%CUDARelease%到path中,CUDARelease爲設置的系統變量名稱)
將編譯需要的頭文件放到vs2008環境中
複製C:ProgramDataNVIDIA CorporationNVIDIA GPU Computing SDKCcommon目錄到C:UsersdawningDocumentsVisual Studio 2008下
4、 VS2008建立CUDA簡單的工程
將模板項目C:ProgramDataNVIDIA CorporationNVIDIA GPU Computing SDKCsrc template拷貝到vs2008項目目錄C:UsersdawningDocumentsVisual Studio 2008Projects
打開vs2008,打開模板項目template_vc90