码迷,mamicode.com
首页 > Web开发 > 详细

【记录】 编译matconvnet on ubuntu16.04 with cuda 9.0

时间:2018-03-18 12:01:33      阅读:1557      评论:0      收藏:0      [点我收藏+]

标签:body   inline   AC   编译   tla   tps   you   机器   iss   

最近需要用到matconvnet 在Ubuntu16.04下。 因为TensorFlow 1.6 支持了CUDA 9.0 所以新机器就直接装了9.0 但是编译matconvnet 时遇到了一些问题 特此记录一下。

 

1. Error using mex nvcc fatal   : Unsupported gpu architecture ‘compute_20‘

Solution: 这个是因为cuda 8 之后不支持compute_20 了,最低也是compute_30了。 所以需要将vl_compilenn.m中的以下代码进行修改

opts.defCudaArch = [...
‘-gencode=arch=compute_20,code=\"sm_20,compute_20\" ‘...
‘-gencode=arch=compute_30,code=\"sm_30,compute_30\"‘];

我用的是GTX1080TI, 此处我修改成

opts.defCudaArch = [...
‘-gencode=arch=compute_30,code=\"sm_30,compute_30\" ‘...
‘-gencode=arch=compute_50,code=\"sm_50,compute_50\"‘];

同时还需要将 matconvnet/matlab/src/config/mex_CUDA_glnxa64.xml 里对应的地方也进行修改 

NVCCFLAGS="-D_FORCE_INLINES -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=\"sm_30,compute_30\" $NVCC_FLAGS"

修改后:

NVCCFLAGS="-D_FORCE_INLINES -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_50,code=\"sm_30,compute_30\" $NVCC_FLAGS"

 

2. Error: matlab/src/bits/impl/pooling_gpu.cu(163): error: function "atomicAdd(double , double)" has already been defined

这个的原因是CUDA6.0 后定义了atomicAdd 所以会出现重复定义的错误。 一共有两个文件里存在这个重复定义的问题,分别在

pooling_gpu.cu, line 163
(commented out atomicadd)

bilinearsampler_gpu.cu, line 25
(commented out atomicadd)

Solution: 这个的解决方式是在这两个文件里定义如下的宏

#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 600
#else
<... place here your own pre-pascal atomicAdd definition ...>
#endif

将如上的定义复制到如上文件里的头部, 将文件里定义的atomicadd function 剪切放在<... place here your own pre-pascal atomicAdd definition ...> 中。

 

 

Reference: Compiling with cuda8 https://github.com/vlfeat/matconvnet/issues/575

【记录】 编译matconvnet on ubuntu16.04 with cuda 9.0

标签:body   inline   AC   编译   tla   tps   you   机器   iss   

原文地址:https://www.cnblogs.com/xyzzhangfan/p/8594326.html

(0)
(2)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!