【问题标题】:Undefined reference error when using mexcuda ubuntu使用 mexcuda ubuntu 时出现未定义的引用错误
【发布时间】:2019-06-03 03:57:30
【问题描述】:

我已经在 ubuntu 上安装了 matlab、gcc 和 CUDA 工具包。使用 mexcuda 。

但是当我编译时出现以下错误,我无法在任何地方找到关于它们的任何引用。

Error using mex
/tmp/mex_42185702054896_15548/testmem04.o: In function `mexFunction':
tmpxft_00003e3a_00000000-5_testmem04.compute_70.cudafe1.cpp:(.text+0x152): undefined reference
to `__cudaPushCallConfiguration'
/tmp/mex_42185702054896_15548/testmem04.o: In function `__device_stub__Z9MulKernelPhPi(unsigned
char*, int*)':
tmpxft_00003e3a_00000000-5_testmem04.compute_70.cudafe1.cpp:(.text+0x35e): undefined reference
to `__cudaPopCallConfiguration'
collect2: error: ld returned 1 exit status

请注意,当我第一次安装 matlab 时,它不支持 cuda 10(我当前的版本),我在 windows 上安装 matlab 时遇到了同样的问题,并通过在文件“nvcc_g++.xml”中注释一行来修复它“而且它有效。当我在 ubuntu matlab 中执行此操作时,matlab 现在检测到 nvcc 编译器,但我得到了以前的错误。

我意识到“未定义的引用错误”是链接器错误,我该怎么办?我尝试链接到 cuda 库,但没有用。

【问题讨论】:

  • 你可能没有链接你需要的库。
  • @AnderBiguri 我怎么知道哪些库是必需的? ,当我用谷歌搜索时,我没有得到任何有用的结果。
  • 好吧,要么你已经编写了代码,并且你知道你正在使用什么功能,要么编写代码的人应该已经通知了你。但是,这可能与 cc=70 有关。你有哪个 GPU?
  • @AnderBiguri 我编写了代码,它在 windows 上运行良好,但是当我尝试在 ubuntu 上复制环境时出现这些错误。我使用 GTX 1060 6gb
  • 为什么要使用 cc=70 标志进行编译?尝试从nvcc 选项中删除它,首先仅针对系统的计算能力进行编译。

标签: matlab cuda mex


【解决方案1】:

对于mexcuda,将 CUDA 工具包与随 MATLAB(和 Parallel Computing Toolbox)一起安装的版本相匹配至关重要。这是因为 Parallel Computing Toolbox 从 CUDA 工具包中提供了一系列库,并希望能够链接到它们。如果您使用错误版本的 CUDA 工具包,各种事情都可能出错。

要检查 CUDA 工具包的适当版本,请查看 gpuDevice 输出中显示的 CUDA ToolkitVersion 版本。

(请注意,只有 toolkit 版本需要与 MATLAB & PCT 匹配 - 获取最新驱动程序几乎总是可以的)。

有关更多详细信息,请在 MATLAB Answers 上查看我的答案 https://uk.mathworks.com/matlabcentral/answers/432360-after-uninstalling-cuda-toolkit-still-matlab-responds-for-gpudevice

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-05-22
    • 2021-03-14
    • 1970-01-01
    • 2015-03-28
    • 1970-01-01
    • 2022-07-15
    • 2018-11-27
    相关资源
    最近更新 更多