【matconvnet】故障排除:Error using mex nvcc fatal : Unsupported gpu architecture 'compute_52'

在matlab中编译matconvnet的时候出现了“Error using mex nvcc fatal   : Unsupported gpu architecture 'compute_52'”这个错误,怎么办呢?

环境:ubuntu 14.04,matlab2014a, 师兄们装好了cuda之类的东西,之前用着都没问题。

然后我新下载了一个matconvnet,1.7版的,要编译一个GPU版本。

然后就是vl_compilenn里面的enableGPU改成true之类的。

一运行,果断报错。

Error using mex nvcc fatal   : Unsupported gpu architecture 'compute_52'

就是说nvcc不支持compute_52                                                                     

上网查了一下,

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Long Name     Short Name     Description
--gpu-architecture arch     -arch     

Specify the name of the class of NVIDIA virtual GPU architecture for which the CUDA input files must be compiled.

With the exception as described for the shorthand below, the architecture specified with this option must be a virtual architecture (such as compute_20). Normally, this option alone does not trigger assembly of the generated PTX for a real architecture (that is the role of nvcc option --gpu-code, see below); rather, its purpose is to control preprocessing and compilation of the input to PTX.

For convenience, in case of simple nvcc compilations, the following shorthand is supported. If no value for option --gpu-code is specified, then the value of this option defaults to the value of --gpu-architecture. In this situation, as only exception to the description above, the value specified for --gpu-architecture may be a real architecture (such as a sm_20), in which case nvcc uses the specified real architecture and its closest virtual architecture as effective architecture values. For example, nvcc --gpu-architecture=sm_20 is equivalent to nvcc --gpu-architecture=compute_20 --gpu-code=sm_20,compute_20.

See Virtual Architecture Feature List for the list of supported virtual architectures and GPU Feature List for the list of supported real architectures.

Read more at: http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#ixzz3xCfVDAF9
Follow us: @GPUComputing on Twitter | NVIDIA on Facebook

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

matlab也提示了那个xml文件有问题,我改了一下,把里面的--gpu-architecture=compute_20 --gpu-code=sm_20,compute_20中的20改成了52.

看网上的那段提示似乎是要在terminal里面输入nvcc --gpu-architecture=compute_20 --gpu-code=sm_20,compute_20之类的:

结果呢?

nvcc --gpu-architecture=compute_52 --gpu-code=sm_52,compute_52

nvcc fatal   : Value 'compute_52' is not defined for option 'gpu-architecture'                                                                                                                             

nvcc --gpu-architecture=sm_50

nvcc fatal   : No input files specified; use option --help for more information     

哎哎哎,等等,这里貌似说的是没有输入文件啊!意思就是这个“50”的值是允许的!!!

突然想起来貌似师兄也提过这个“计算能力”要取整数之类的。

但是vl_compilenn是在matlab里运行的啊,没有显示地调用nvcc,怎么改变这个参数啊?

读代码。。。

发现这个“arch”是在这里确定的:

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function cudaArch = get_cuda_arch(opts)
% --------------------------------------------------------------------
opts.verbose && fprintf('%s:\tCUDA: determining GPU compute capability (use the ''CudaArch'' option to override)\n', mfilename);
try
  gpu_device = gpuDevice();
  arch_code = strrep(gpu_device.ComputeCapability, '.', '');
  cudaArch = ...
      sprintf('-gencode=arch=compute_%s,code=\\\"sm_%s,compute_%s\\\" ', ...
              arch_code, arch_code, arch_code) ;
catch
  opts.verbose && fprintf(['%s:\tCUDA: cannot determine the capabilities of the installed GPU;' ...
                      'falling back to default\n'], mfilename);
  cudaArch = opts.defCudaArch;
end

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

我们已经知道了我们的计算能力是52,跟我们最近的,nvcc又支持的,是50.

于是乎,简单粗暴地强行让cudaArch为50即可。

运行了一下这段代码看cudaArch的格式。

最终得到解决方案:

在这句代码下面:

  cudaArch = ...
      sprintf('-gencode=arch=compute_%s,code=\\\"sm_%s,compute_%s\\\" ', ...
              arch_code, arch_code, arch_code) ;

直接加一句:

  cudaArch ='-gencode=arch=compute_50,code=\"sm_50,compute_50\" ';

强行让cudaArch等于我们想要的值即可。

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值