顯示具有 cuda 標籤的文章。 顯示所有文章
顯示具有 cuda 標籤的文章。 顯示所有文章

星期六, 5月 09, 2015

CUDA:Can not find cutil32D.lib ...

Problem :  SDK (e.g. OpenCV, OptiX) 和本機 CUDA  32 bits or 64 bits 間選用了不同平台.

Solution 

step 1 :重新編譯適當平台的 cutil library.  位在 
C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\CUDALibraries\common\ 

step 2 : 將不同平台產生的 cutil32D.lib/cutil64D.lib 加入 linker   
Linker -> General -> Additional Library Directories 

由於 step 1 不同平台的 library 會置於不同 path, 將有平台變數的 path

  
 $(NVSDKCOMPUTE_ROOT)\C\common\lib\$(PlatformName)
   $(NVSDKCOMPUTE_ROOT)\shared\lib\$(PlatformName)
加入 Linker -> General -> Additional Library Dire

p.s. 
 win7 找環境變數 …
電腦 -> 變更設定 -> 系統內容 -> 環境變數
NVSDKCOMPUTE_ROOT=C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.1

Step 3 : 如果不幸地出現因 cutil 引起的 error lnk2005 … already define in LIBCMTD.lib
        [Debug/Win32]
        1.  C++ 改用 /MTd 編譯
                C/C++ -> Code Generation change the Runtime Library to/MTd        2.  忽略 LIBCMT.lib
                Linker->Input->Ignore Specific Library to  libcmt.lib
        3.   CUDA 的 Host code (CPU code) 也以  /MTd 編譯                        CUDA Runtime API -> Host -> Runtime Library => /MTd

                [Release/Win32]
                1.  C++ 改用 /MT 編譯
                        C/C++ -> Code Generation change the Runtime Library to /MT
                2.  忽略 LIBCMTD.lib
                        Linker->Input->Ignore Specific Library to  libcmtd.lib 
                3.   CUDA 的 Host code (CPU code) 也以  /MT 編譯                       CUDA Runtime API -> Host -> Runtime Library => /MTd 
             

        p.s
. 曾經同時忽略 libcmt.lib 和 libcmtd.lib, 反而出現更多 error lnk2005 ! 

Reference link

CUDA: Rule File in VC2008

執行 CUDA file (.cu) 時, 如果發生某某預期的 header file 不能讀取, 很可能是 CUDA file 沒有使用正確的 CUDA rules, 或是該 rule file 的 include path 不正確.

以下是 VS2008/VC++ 下設定 cuda rules 的方法


1. 一般來說, cuda rule 會置於VCProjectDefaults 下, 如下

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\VCProjectDefaults
  1. NvCudaDriverApi.rules
  2. NvCudaDriverApi.v4.0.rules
  3. NvCudaRuntimeApi.rules
  4.  
  1.  
  1. NvCudaRuntimeApi.v4.0.rules

2. 如果是自訂的 project, 得先確認 project 有 CUDA Build rules.  可右擊 project, 點選"Custom Build Rules ..."; 對話盒出現 Build Rule Files 後, 點選適當的 rule path
                
        

     

3. 再指定 .cu file 使用 cuda rules..  可對該 cuda file 右擊, 點選 Properties



4. 出現該 cuda file 的 Property Pages 後指定 Tool. 本例中使用 CUDA Runtime API (會因為之前選擇的 CUDA rule file 不同而改變)

Configuration Properties > General > Tool  = "CUDA Runtime API"

5. 設定 Additional Include Directories
Configuration Properties > CUDA Runtime API > General > Additional Include Directories


Reference links
http://forums.nvidia.com/index.php?showtopic=30273http://forums.nvidia.com/index.php?showtopic=167114