2013-10-14 52 views
7

我剛安裝CUDA和一直關注http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-mac-os-x/index.html試圖讓CUDA工作,樣品找不到helper_cuda.h

一切工作,直到我試圖複製樣本代碼,如DEVICEQUERY到〜/臺式機和編譯。

我收到以下錯誤,在編譯:

/Developer/NVIDIA/CUDA-5.5/bin/nvcc -ccbin g++ -I../../common/inc -m64 -Xcompiler -arch -Xcompiler x86_64 -gencode arch=compute_10,code=sm_10 -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=\"sm_35,compute_35\" -o deviceQuery.o -c deviceQuery.cpp 
deviceQuery.cpp:23:25: error: helper_cuda.h: No such file or directory 
deviceQuery.cpp: In function ‘int main(int, char**)’: 
deviceQuery.cpp:111: error: ‘SPRINTF’ was not declared in this scope 
deviceQuery.cpp:116: error: ‘_ConvertSMVer2Cores’ was not declared in this scope 
deviceQuery.cpp:206: error: ‘checkCudaErrors’ was not declared in this scope 
deviceQuery.cpp:230: error: ‘checkCudaErrors’ was not declared in this scope 
deviceQuery.cpp:241: error: ‘checkCudaErrors’ was not declared in this scope 
make: *** [deviceQuery.o] Error 1 

的代碼將編譯並在CUDA目錄下運行,這是明確的編譯器無法找到helper_cuda.h,我找不到它要麼有沒有人有解決方案?

回答

18

如您的編譯選項-I../../common/inc,helper_cuda.h所示,位於$CUDA_HOME/samples/common/inc/

如果要將樣本複製到自定義位置,則必須複製整個samples目錄,或者修改一些代碼/編譯選項以包含common/ dir中的工作人員。

0

http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#environment-setup

的NVIDIA CUDA工具包,包括源形式的示例程序。您應該通過更改〜/ NVIDIA_CUDA-8.0_Samples並鍵入make來編譯它們。生成的二進制文件將在〜/ NVIDIA_CUDA-8.0_Samples/bin中

放在只要確保:

$ export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}

$ export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64\ ${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

$ nvcc -V

應該顯示的版本。

$ cd ~/some_path/NVIDIA_CUDA-8.0_Samples

$ make