2011-05-14 6 views
2

CUDA from an Ubuntu PPA을 설치했습니다. 이제 설치를 테스트하고 싶습니다.CUDA from Ubuntu PPA : 첫 번째 CUDA 프로그램 컴파일

나는 small sample program from another StackOverflow post을 움켜 잡았다. cuda.h 및 cuda_runtime.h를 가져옵니다. 이것은 nvcc를 사용하여 프로그램을 컴파일해야하거나 gcc를 사용해야합니까?

내가 컴파일하려고하면 아래 오류가 발생합니다. 컴파일러에게 필요한 라이브러리를 찾는 위치를 알려주려면 어떻게해야합니까? 또한, 어떻게 내가 그 도서관을 직접 찾을 수 있습니까? PPA 설치가 어디에 설치되었는지 또는 내가 찾고 있어야하는 라이브러리의 이름을 모르겠습니다.

detect_cuda.c:(.text+0x2b): undefined reference to `cudaGetDeviceCount' 
detect_cuda.c:(.text+0x30): undefined reference to `cudaGetLastError' 
detect_cuda.c:(.text+0x47): undefined reference to `cudaGetErrorString' 
detect_cuda.c:(.text+0xba): undefined reference to `cudaGetDeviceProperties' 
+3

'-lcudart'를 링커/컴파일러에 추가하십시오. – Anycorn

+0

그래, 그랬어. 감사! –

+0

하지만 이것이 필요한 이유는 무엇입니까? 'lcudart' 나'cudart'에 대해'nvcc -h'를 검색하면 아무것도 찾을 수 없습니다. cuda 런타임을 링크하는 것처럼 보이지만 이것이 필요한 이유는 무엇입니까? – solgar

답변

2

-lcudart를 추가하면 주석에 제안 된 Anycom처럼 작동합니다.

nvcc -lcudart detect_cuda.cu