【问题标题】:Error while compiling Hello world program for CUDA为 CUDA 编译 Hello world 程序时出错
【发布时间】: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 是的,有参考文献

标签: c cuda gpu nvidia


【解决方案1】:

我认为,这些链接会对您有所帮助。

Developer Drivers安装视频演示

使用相同的命令行安装工具包和 sdk。

每次打开终端时都需要更改目录。这些说明在Linux Installation的第11页中给出

在一切之前,您需要从Developers Page. 下载 .run 文件

【讨论】:

    猜你喜欢
    • 2022-07-13
    • 2014-07-19
    • 2011-12-28
    • 2011-03-21
    • 2016-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多