【问题标题】:CUDA from Ubuntu PPA: Compiling first CUDA program来自 Ubuntu PPA 的 CUDA:编译第一个 CUDA 程序
【发布时间】:2011-05-14 07:38:37
【问题描述】:

我安装了CUDA from an Ubuntu PPA。现在我想测试安装。

我抓住了small sample program from another StackOverflow post。它导入 cuda.h 和 cuda_runtime.h。这是否意味着我需要使用 nvcc 来编译程序还是应该使用 gcc?

当我尝试编译时,出现以下错误。我如何告诉编译器在哪里可以找到必要的库?另外,我自己如何找到这些库?我不确定 PPA 安装将它们放在哪里或我应该寻找的库的名称。

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'

【问题讨论】:

  • -lcudart 添加到链接器/编译器
  • 但是为什么需要这个?如果我在nvcc -h 中搜索lcudartcudart,我什么也找不到。它看起来像链接 cuda 运行时,但为什么甚至需要呢?

标签: c cuda


【解决方案1】:

添加 -lcudart 就像 Anycom 在 cmets 中建议的那样工作。

nvcc -lcudart detect_cuda.cu

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-14
    • 2012-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-13
    相关资源
    最近更新 更多