【发布时间】:2012-10-24 08:21:35
【问题描述】:
我使用的是 Ubuntu 12.10,并且也成功安装了 CUDA 5.0 及其示例套件。我还运行了sudo apt-get install nvidia-cuda-toolkit 下面是我的 CUDA hello world 程序:
#include <stdio.h> /* Core input/output operations */
#include <stdlib.h> /* Conversions, random numbers, memory allocation, etc. */
#include <math.h> /* Common mathematical functions */
#include <time.h> /* Converting between various date/time formats */
#include <cuda.h> /* CUDA related stuff */
__global__ void kernel(void) {
}
/* MAIN PROGRAM BEGINS */
int main(void) {
/* Dg = 1; Db = 1; Ns = 0; S = 0 */
kernel<<<1,1>>>();
/* PRINT 'HELLO, WORLD!' TO THE SCREEN */
printf("\n Hello, World!\n\n");
/* INDICATE THE TERMINATION OF THE PROGRAM */
return 0;
}
/* MAIN PROGRAM ENDS */
我用nvcc -g hello_world_cuda.cu -o hello_world_cuda.x编译时出现如下错误
/tmp/tmpxft_000033f1_00000000-13_hello_world_cuda.o: In function `main':
/home/adarshakb/Documents/hello_world_cuda.cu:16: undefined reference to `cudaConfigureCall'
/tmp/tmpxft_000033f1_00000000-13_hello_world_cuda.o: In function `__cudaUnregisterBinaryUtil':
/usr/include/crt/host_runtime.h:172: undefined reference to `__cudaUnregisterFatBinary'
/tmp/tmpxft_000033f1_00000000-13_hello_world_cuda.o: In function `__sti____cudaRegisterAll_51_tmpxft_000033f1_00000000_4_hello_world_cuda_cpp1_ii_b81a68a1':
/tmp/tmpxft_000033f1_00000000-1_hello_world_cuda.cudafe1.stub.c:1: undefined reference to `__cudaRegisterFatBinary'
/tmp/tmpxft_000033f1_00000000-1_hello_world_cuda.cudafe1.stub.c:1: undefined reference to `__cudaRegisterFunction'
/tmp/tmpxft_000033f1_00000000-13_hello_world_cuda.o: In function `cudaError cudaLaunch<char>(char*)':
/usr/lib/nvidia-cuda-toolkit/include/cuda_runtime.h:958: undefined reference to `cudaLaunch'
collect2: ld returned 1 exit status
我还确保我使用 gcc 和 g++ 4.4 版(因为 4.7 CUDA 存在一些问题)
【问题讨论】:
-
目前没有支持 Ubuntu 12.10 的 cuda 5 包。您的程序在我安装在 RHEL 5.5 上的 cuda 5 上运行良好。如果您运行了 cuda 5 安装程序包,然后又运行了 sudo apt-get nvidia-cuda-toolkit,那么您的安装可能不匹配。您可以使用安装程序或 apt-get 来安装工具包,而不是两者都安装。您可能需要重新开始安装,推荐的方法是使用推荐的发行版。
-
还要检查您的路径和 ldconfig。 "echo $PATH" "ldconfig -p | grep cu" 有没有提到 cuda?
-
@adray 是的,有参考文献