简体   繁体   English

为CUDA编译Hello world程序时出错

[英]Error while compiling Hello world program for CUDA

I am using Ubuntu 12.10 and have sucessfully installed CUDA 5.0 and its sample kits too. 我正在使用Ubuntu 12.10,并成功安装了CUDA 5.0及其示例工具包。 I have also run sudo apt-get install nvidia-cuda-toolkit Below is my hello world program for CUDA: 我还运行了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 */

The following error occurs when I compile it with nvcc -g hello_world_cuda.cu -o hello_world_cuda.x 当我使用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

I am also making sure that I use gcc and g++ version 4.4 ( As 4.7 there is some problem with CUDA) 我还要确保我使用的是gcc和g ++版本4.4(作为4.7,CUDA存在一些问题)

I think, these links will help you. 我认为,这些链接将为您提供帮助。

Video demo of installation of Developer Drivers 开发者驱动程序安装的视频演示

Use the same command lines to install toolkit and sdk. 使用相同的命令行来安装工具箱和sdk。

You need to change the directories when you open terminal every time. 每次打开终端时都需要更改目录。 Those instructions are given in page-11 of Linux Installation 这些说明在Linux安装的第11页中给出

Before everything, you need to download the .run files from the Developers Page. 开始之前,您需要从开发人员页面下载.run文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM