CUDA3.1 X32 + Windows 7 32bit + Visual Studio 2005 + Visual assist安裝指南

1. 安裝CUDA Driver,toolkit,SDK

a) 建議driver,toolkit,SDK的順序,默認路徑安裝

b) 如果筆記本用戶,可以選擇強行安裝3.1的驅動包(選擇對應臺式機的型號),但是會有部分遊戲隨機花屏等問題。可以裝2.2就有筆記本驅動

2. 安裝Visual studio 2005

3. 安裝wizard x32版

4. 環境配置

a) 將

i. C:/Documents and Settings/All Users/Application Data/NVIDIA Corporation/NVIDIA GPU Computing SDK/C/bin/win32/Debug;

ii. C:/Documents and Settings/All Users/Application Data/NVIDIA Corporation/NVIDIA GPU Computing SDK/C/bin/win32/emudebug;

iii. C:/Documents and Settings/All Users/Application Data/NVIDIA Corporation/NVIDIA GPU Computing SDK/C/bin/win32/release;

添加到path中

b) 打開vs2005,工具,選項,項目和解決方案,VC++目錄,

庫文件中添加

C:/Documents and Settings/All Users/Application Data/NVIDIA Corporation/NVIDIA GPU Computing SDK/C/common/lib

C:/CUDA/lib

包含文件中添加

C:/CUDA/include

C:/Documents and Settings/All Users/Application Data/NVIDIA Corporation/NVIDIA GPU Computing SDK/C/common/inc

源文件中添加

C:/Documents and Settings/All Users/Application Data/NVIDIA Corporation/NVIDIA GPU Computing SDK/C/common/src

c) VC++項目設置,

d) C/C++擴展名添加*.cu

e) 包含擴展名添加.cuh

f) 規則文件搜索路徑設爲

C:/Documents and Settings/All Users/Application Data/NVIDIA Corporation/NVIDIA GPU Computing SDK/C/common

g) 到此可以新建一個項目測試一下hello cuda能否運行。

h) 調試程序時

在工程上右鍵選custom build rules->Find Existing,選中cuda.rules,點擊ok。

在工程上右鍵選屬性,在CUDA中

GPU Architecture選擇sm_13

Use Fast Math 選擇“是”

Optimization選擇Maximize speed或Full Optimization

Set the default "CUDA -> Advanced -> GPU Architecture Compile Name" as "1.0(virtual) Arch", You may change it depends on your system.

Set the default "CUDA -> Advanced -> GPU Architecture Code Name" as "1.0(hardware) code", You may change it depends on your system.

Set the default "CUDA -> Output -> Inern Mode" as "Real" in Debug & Release;

5. 安裝Visual Assist

破解版一大堆自己找吧

6. VA配置

a) 將C:/Documents and Settings/All Users/Application Data/NVIDIA Corporation/NVIDIA GPU Computing SDK/C/doc/syntax_highlighting/visual_studio_8中的usertype.dat拷貝到C:/Program Files/Microsoft Visual Studio 8/Common7/IDE中

b) 打開VS2005,選擇工具-選項-文本編輯器-文件擴展名,在擴展名編輯框中填入cu,在編輯器下拉菜單中選擇Microsoft Visual C++,單擊添加,然後點擊確定。

c) 打開註冊表,在HKEY_LOCAL_MACHINE/SOFTWARE /Microsoft/VisualStudio/9.0/Languages/File Extensions/.cpp下面添加子鍵 .cu 然後copy .cpp的鍵值到.cu。這樣才能表示cu也是VS下的VC的工程文件。

d) 打開VS,運行下VA(建立一個CPP工程,折騰到VA能用爲止),關掉IDE,否則註冊表不會添加對應信息。

e) HKEY_CURRENT_USER/Software/Whole Tomato/Visual Assist X/VANet8 在ExtSource鍵添加鍵值.cu

f) 打開Visual Assist屬性,在projects 的C/C++ Directories custom下面添加CUDA的頭文件目錄,這樣才能在Visual Assist 生成規則的時候找到CUDA自身的特殊定義才能生成Visual Assist的關鍵字,如__global__.

添加的目錄有C:/CUDA/include,C:/Documents and Settings/All Users/Application Data/NVIDIA Corporation/NVIDIA GPU Computing SDK/C/common/inc

Source file中添加C:/Documents and Settings/All Users/Application Data/NVIDIA Corporation/NVIDIA GPU Computing SDK/C/common/src


經驗:

fatal error LNK1181: 無法打開輸入文件“cutil32D.lib”,雖然安裝了cuda Toolkit和cuda SDK,但是沒有這個文件。


解決方法:

  在SDK的安裝目錄的下級目標 C\common\ 裏面有cutil_xxx之類的工程(後面的xxx是vs2008或vs2010),用vs打開工程,選“批生成”(我直接Debug了一下),把所有配置的lib都生產,或自己選配置生成需要的lib。

  這樣就有了cutil32D.lib

  之後添加路徑,具體的方法是在VS2008裏面Tools->Options->Projects and Solutions下的VC++ Directories,在右邊添加相應的目錄(include和lib)。最方便的是在環境變量裏面添加相應的環境變量,並添加好目錄,那麼在這裏添加的話,直接將環境變量的名字直接添加進來就可以了。添加環境變量時,添加進系統變量,註銷重新登錄系統就可以生效了。

  編譯時應選擇生成規則中的cuda規則,否則#include <*.cu> 會提示找不到該文件。

  若程序編譯時出現重複定義的錯誤,則在kernel函數聲明前前缺少static,正確應該如下:__global__ static void (保證該函數只能在本文件中的函數所調用,不能被其他文件所調用)因此不會出現以上重定義現象

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章