分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 运营维护

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

发布时间:2023-09-06 01:46责任编辑:沈小雨关键词:编译

最近需要用到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

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

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved