【问题标题】:About the program "Hello world" from CUDA C on linux关于 Linux 上 CUDA C 的程序“Hello world”
【发布时间】:2016-12-23 09:57:00
【问题描述】:

我需要帮助。 我是linux的新用户。我安装了 CUDA C 驱动程序。我已经测试了带宽样本,它运行良好。当我编译这个程序时:

 #include <stdio.h>
__global__ void helloFromGPU (void)
{
printf("Hello World from GPU!\n");
}
int main(void)
{
// hello from cpu
printf("Hello World from CPU!\n");
helloFromGPU <<<1, 10>>>();
cudaDeviceReset();
return 0;
}

并尝试执行我得到的二进制文件

$ ./code_1
Hello World from CPU!

并且设备代码没有显示重复字符串 10 次的预期结果。 亲爱的罗伯特,我得到了这个结果:

  yasin@yasin-Inspiron-5558:~/Documents/Programming$ cuda-memcheck ./code_1
    ========= CUDA-MEMCHECK
    Hello World from CPU!
    ========= ERROR SUMMARY: 0 errors
    yasin@yasin-Inspiron-5558:~/Documents/Programming$ 

我已经按照你的要求做了@Robert:

$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2013 NVIDIA Corporation
Built on Wed_Jul_17_18:36:13_PDT_2013
Cuda compilation tools, release 5.5, V5.5.0
yasin@yasin-Inspiron-5558:~$ nvidia-smi
Failed to initialize NVML: Unknown Error
yasin@yasin-Inspiron-5558:~$ 

【问题讨论】:

  • 1.在cudaDeviceReset(); 之前添加cudaDeviceSynchronize(); 2. 使用cuda-memcheck 运行您的代码并报告结果。
  • 结果不是预期的。有什么问题?
  • 使用 cuda-memcheck 运行代码时的实际输出是什么?请复制输出并将其粘贴到您的问题中。您可以编辑您的问题,只需点击上方linuxcuda 标签下方的编辑链接即可。像这样:cuda-memcheck ./code_1
  • 亲爱的 Ropert,首先感谢您的帮助。其次,我得到了这个结果:========= CUDA-MEMCHECK ========= code_1.cu: Permission denied ========= 错误摘要:0 个错误
  • 那不正确。你不想运行cuda-memcheck ./code_1.cu 你想运行cuda-memcheck ./code_1

标签: linux cuda


【解决方案1】:

问题只是没有正确安装 CUDA。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-09
    • 1970-01-01
    • 1970-01-01
    • 2012-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多