【发布时间】: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选项中删除它,首先仅针对系统的计算能力进行编译。