我如何获得Matlab的mexcuda命令在ubuntu 20.04中找到gcc版本8?

时间:2020-07-10 15:50:20

标签: matlab cuda ubuntu-20.04

我正在尝试使用MATLAB的CUDA来编译一些GPU上的代码。当我运行命令

mexcuda -largeArrayDims mexThSpkPC.cu

我收到以下错误:

>> mexcuda -largeArrayDims mexThSpkPC.cu
Building with 'nvcc'.
Error using mex
In file included from /usr/include/cuda_runtime.h:83,
                 from <command-line>:
/usr/include/crt/host_config.h:138:2: error: #error -- unsupported GNU version! gcc versions later than
8 are not supported!
  138 | #error -- unsupported GNU version! gcc versions later than 8 are not supported!
      |  ^~~~~


Error in mexcuda (line 166)
    [varargout{1:nargout}] = mex(mexArguments{:});

奇怪的是,我已经从apt安装了nvidia-cuda-toolkit,并且同时引入了gcc版本8和g++。因此它们在我的系统上。如何获取MATLAB(或nvida CUDA编译器)以找到正确版本的gcc / g++?我正在使用Ubuntu 20.04。

1 个答案:

答案 0 :(得分:1)

进行一些挖掘之后,我发现MATLAB代码正在寻找CUDA_PATH环境变量。因此,将matlab开头为:

CUDA_PATH=/usr/lib/nvidia-cuda-toolkit  matlab

为我解决了问题!