2013-11-02 68 views
0

我試圖彙編nsight一個CUDA 5.5的應用程序與Ubuntu 12.04關聯問題CUDA 5.5 nsight

起初,我得到了一個問題,關於缺少的頭文件,如#include <helper_cuda_drvapi.h>

爲了解決這個問題,我添加了路徑/usr/include/samples/common/inc我包括列表。

這解決了缺少頭文件的問題,而是造成了新的問題。

試圖編譯上nsight程序時,我得到了以下錯誤

/usr/local/cuda-5.5/samples/common/inc/helper_cuda_drvapi.h:278:未定義的引用cuInit' /usr/local/cuda-5.5/samples/common/inc/helper_cuda_drvapi.h:279: undefined reference to cuDeviceGetCount」 /usr/local/cuda-5.5/samples/common/inc/helper_cuda_drvapi.h:290:未定義參照cuDeviceGetName' /usr/local/cuda-5.5/samples/common/inc/helper_cuda_drvapi.h:291: undefined reference to cuDeviceComputeCapability」 /usr/local/cuda-5.5/samples/common/inc/helper_cuda_drvapi.h:294:未定義參照cuDeviceGetAttribute' /usr/local/cuda-5.5/samples/common/inc/helper_cuda_drvapi.h:327: undefined reference to cuDeviceGetAttribute」 /usr/local/cuda-5.5/samples/common/inc/helper_cuda_drvapi.h:330:未定義參照cuDeviceGetAttribute' /usr/local/cuda-5.5/samples/common/inc/helper_cuda_drvapi.h:333: undefined reference to cuDeviceComputeCapability ' /usr/local/cuda-5.5/samples/common/inc/helper_cuda_drvapi.h:336:未定義的引用`cuDeviceGetAttribute'

有什麼建議?

在此先感謝

***************** UPDATE ************

什麼它基本上可以歸結到是我試圖編譯Linux上的「CUDA視頻解碼器GL API」示例程序,它是不是因爲一些錯誤與頭文件的工作。有人知道爲什麼嗎?

UPDATE

enter image description here

enter image description here

enter image description here

enter image description here

+1

嘗試,包括之前''helper_cuda_drvapi.h'和cuda.h''cuda_runtime.h'。 –

+0

我看到他們是如何用nvcc修復它的,但我認爲沒有辦法設置先用nsight編譯的東西 – user2719805

+0

@RogerDahl我相信你的評論是正確的。 OP顯然不理解它,也沒有nsight EE和nvcc之間的區別。你能否將你的評論擴展爲答案?我會贊成它。 –

回答

2

未定義的引用是對CUDA驅動程序API方法。 helper_cuda_drvapi.h具有靠近頂部的評論:用於CUDA驅動程序API錯誤處理

輔助功能(確保CUDA_H包含在你的項目)

所以,在你.cu.cpp文件,前在#include <helper_cuda_drvapi.h>,包括cuda.h

#include "cuda.h" 
#include <helper_cuda_drvapi.h> 

有關CUDA頭的詳細信息,請參閱this question

+0

我已經完成了這個工作,但當我在nsight中編譯程序時,我仍然遇到同樣的錯誤 – user2719805

2

您需要手動libcuda鏈接(Nsight項目中使用運行時API)

要與此庫鏈接:

  1. 轉到屬性爲您的項目,開一般/路徑和符號
  2. tab add cuda(不帶前綴或後綴 - 理論上應該讓你的項目更加clossplatform。添加庫時,您可能還想檢查「添加到所有配置」 - 否則它將用於您當前的構建配置(例如,僅「調試」或「發佈」)。

更新:項目設置截圖: enter image description here

+0

我也這樣做了,我開始認爲它是因爲DirectX而在Windows上運行,但它確實不適用於Linux,因爲它不支持DirectX – user2719805

+0

我在Linux上測試過它。可以肯定 - 我在Roger的建議下添加了#include ,並添加了'-lcuda'鏈接器標誌。 – Eugene

+0

等你拿到「CUDA Video Decoder GL API」在linux上運行 如果是這樣,請讓我知道你使用它的確切命令 – user2719805