开发者

CUDA from Ubuntu PPA: Compiling first CUDA program

I installed CUDA from an Ubuntu PPA. Now 开发者_JAVA百科I want to test the installation.

I grabbed a small sample program from another StackOverflow post. It imports cuda.h and cuda_runtime.h. Does this mean I need to use nvcc to compile the program or should I use gcc?

When I try to compile I get the errors below. How do I tell the compiler where to find the necessary libraries? Also, how do I find those libraries myself? I'm not sure where the PPA installation put them or the names of the libraries I should be looking for.

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'


Adding -lcudart worked as Anycom suggested in the comments.

nvcc -lcudart detect_cuda.cu
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜