Ubuntu16下Matlab2017b安装及matcaffe使用问题记录

版权声明:未经博主允许,不得转载! https://blog.csdn.net/u011681952/article/details/85680067

 本人之前常用matlab2015b来跑caffe,但其在inference网络时,常常出现几个问题:
 1) gpuDevice(1)函数时间太长,约么5分钟左右,急性子人实在受不了
 2)非第一次inference,不用 gpuDevice函数,又常常出现找不到gpu环境错误(具体错误,忘记截图了),需要重启matlab+gpuDevice
 所以恒心升级matlab2017b,具体安装与matlab2015类似。当然也有一篇博客写得很详细,所以我就偷懒盗用下:
ubuntu16.04安装MATLAB R2017b步骤详解(附完整破解文件包

 但个人在使用中有些许个人习惯和问题处理:

 1)在安装2017版本前,若安装来其他版本建议卸载,不是冲突原因,而是matlab太占空间,2015b安装占用约15G,2017b占18.4G,如果你的根目录盘分配资源少,如我的共38G,还有其他安装包,两个matlab肯定受不了

在这里插入图片描述

 2)当然可以将matlab安装在其他位置,添加环境变量即可(没尝试,应该可行);当然如果资源充足,这不是问题
 3)优化阶段:我习惯用软链接代替环境变量方式

sudo ln -s /usr/local/MATLAB/R2017b/bin/matlab   /usr/local/bin/matlab

 4)使用问题:
 安装上述博客安装,肯定是ok的,但跑caffe模型时,报错,我只复制了小部分,后边还有很长的

Invalid MEX-file 'caffe/matlab/+caffe/private/caffe_.mexa64':
Missing symbol '_ZN6google8protobuf11MessageLite15ParseFromStringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE' required by
'caffe/matlab/+caffe/private/caffe_.mexa64'
Missing symbol '_ZN6google8protobuf14MessageFactory29InternalRegisterGeneratedFileEPKcPFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE' required by
'caffe/matlab/+caffe/private/caffe_.mexa64'
Missing symbol '_ZN6google8protobuf2io17CodedOutputStream26WriteStringWithSizeToArrayERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPh' required by
'caffe/matlab/+caffe/private/caffe_.mexa64'
Missing symbol '_ZN6google8protobuf8internal10NameOfEnumB5cxx11EPKNS0_14EnumDescriptorEi' required by 'caffe/matlab/+caffe/private/caffe_.mexa64'
Missing symbol '_ZN6google8protobuf8internal13empty_string_B5cxx11E' required by 'caffe/matlab/+caffe/private/caffe_.mexa64'
Missing symbol '_ZN6google8protobuf8internal14WireFormatLite10ReadStringEPNS0_2io16CodedInputStreamEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE' required by
'caffe/matlab/+caffe/private/caffe_.mexa64'
Missing symbol '_ZN6google8protobuf8internal14WireFormatLite11WriteStringEiRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPNS0_2io17CodedOutputStreamE' required by
'caffe/matlab/+caffe/private/caffe_.mexa64'
Missing symbol '_ZN6google8protobuf8internal14WireFormatLite22WriteBytesMaybeAliasedEiRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPNS0_2io17CodedOutputStreamE'
required by 'caffe/matlab/+caffe/private/caffe_.mexa64'
Missing symbol '_ZN6google8protobuf8internal14WireFormatLite23WriteStringMaybeAliasedEiRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPNS0_2io17CodedOutputStreamE'
required by 'caffe/matlab/+caffe/private/caffe_.mexa64'
Missing symbol '_ZN6google8protobuf8internal14WireFormatLite9ReadBytesEPNS0_2io16CodedInputStreamEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE' required by

 matlab2015b也有类似问题,它是libstdc++库升级造成的,只需要将matlab2015b安装目录下的libstdc++干掉即可,因为系统已经有这个库了
 matlab2017b这个错误,是几个库引起的,读者可仔细看报错信息
 解决:

vim ~/.bashrc
//末尾添加
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6:/usr/local/cuda-8.0/lib64/libcudart.so.8.0:/usr/local/cuda-8.0/lib64/libcublas.so.8.0:/usr/lib/x86_64-linux-gnu/libprotobuf.so.9
//刷新
source ~/.bashrc

 5)添加包:
 在使用matcaffe时,我们可能常常需要添加额外的工具包,如使用Json包(jsonlab-1.5)

//1 复制包到toolbox
cd /usr/local/MATLAB/R2017b
sudo chmod 777 toolbox
sudo cp -r path/jsonlab-1.5  /usr/local/MATLAB/R2017b/toolbox

//2 修改pathdef.h权限
cd /usr/local/MATLAB/R2017b/toolbox/local
sudo chmod 777 pathdef.h

//3 添加包

打开matlab,主页 -> 设置路径 -> 添加并包含子文件夹 -> 找到选择jsonlab-1.5 -> 保存

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/u011681952/article/details/85680067