Ubuntu18.04系统MATLAB2018b调用CUDA 10.1和NVCC

MATLAB2018b默认支持的CUDA版本是CUDA9.1,所以我们直接编译NVCC会出现如下错误

>> vl_compilenn('enableGpu', true)
警告: Version 9.1 of the CUDA toolkit could not be found. If installed, set MW_NVCC_PATH environment variable to
location of nvcc compiler.
 
> In mexcuda (line 157)
  In vl_compilenn>mexcuda_compile (line 603)
  In vl_compilenn (line 489) 
错误使用 mex
未找到支持的编译器。有关选项,请访问 https://www.mathworks.com/support/compilers。

出错 mexcuda (line 157)
    [varargout{1:nargout}] = mex(mexArguments{:});

出错 vl_compilenn>mexcuda_compile (line 603)
mexcuda(args{:}) ;

出错 vl_compilenn (line 489)
      mexcuda_compile(opts, srcs{i}, objfile, flags) ;

我们安装的CUDA版本为10.1,所以只需指定CUDA版本路径即可。

1、打开NVCC配置文件

sudo gedit /usr/local/MATLAB/R2018b/toolbox/distcomp/gpu/extern/src/mex/glnxa64/nvcc_g++.xml

将里面所有的9.1改为10.1,一共六处全部更改。

其实在/usr/local/MATLAB/R2018b/toolbox/distcomp/gpu/extern/src/mex/glnxa64/路径下有两个配置文件nvcc_g++.xml和nvcc_g++_dynamic.xml,保险起见,把两个配置文件都做同样更改。

2、再次编译还会报错

>> vl_compilenn('enableGpu', true)
使用 'nvcc' 编译。
错误使用 mex
nvcc fatal   : '-DNDEBUG': expected a number


出错 mexcuda (line 157)
    [varargout{1:nargout}] = mex(mexArguments{:});

出错 vl_compilenn>mexcuda_compile (line 603)
mexcuda(args{:}) ;

出错 vl_compilenn (line 489)
      mexcuda_compile(opts, srcs{i}, objfile, flags) ;
 

以下三种解决方法,前两种只能用debug模式,推荐使用第三种。

解决方法1:

更改vl_compilenn第179行为“opts.debug = true;”

参考:https://www.cnblogs.com/samwoog/p/matconvnet_installation_problems.html

解决方法2:

运行时初始化为Debug模式

vl_compilenn('enableGpu',true,'Debug',true) 

解决方法3:(最优解决方法)

Matlab2018b使用CUDA10.1错误nvcc fatal : ‘-DNDEBUG‘: expected a number_博博有个大大大的Dream-CSDN博客

3、再次编译可能还会出错

错误使用 mex
/usr/lib/gcc/x86_64-linux-gnu/7/include/avx512fintrin.h(11265): error: identifier "__builtin_ia32_scalefsd_round" is
undefined
/usr/lib/gcc/x86_64-linux-gnu/7/include/avx512fintrin.h(11274): error: identifier "__builtin_ia32_scalefss_round" is
undefined

这个错误可能是g++和gcc的版本过高导致的,将g++和gcc的版本降级即可解决

降级方法:Ubuntu 18.04 将gcc版本降级为5.5版本_阿耀的博客-CSDN博客

4、最后编译成功

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值