您的位置:首页 > 编程语言 > MATLAB

远程服务器 ubuntu16.04 caffe+matlab r2014b+python+cpu-only配置(三)

2018-02-18 17:14 711 查看

Caffe配置过程中的一些问题

参考链接:

https://groups.google.com/forum/#!topic/caffe-users/x8Y26vf-or8

http://blog.csdn.net/striker_v/article/details/52890747

http://www.echojb.com/cuda/2017/05/05/375103.html

http://www.caffecn.cn/?/question/1113

GCC版本太新

在make过程中可能 string.h ‘memcy’ was not declared in this scope的错误,这是因为ubuntu中gcc编译器版本太新,解决方法是打开Makefile文件,找到下面这行代码(大概在409行左右):

NVCCFLAGS += -ccbin=(CXX)−Xcompiler−fPIC(COMMON_FLAGS)


将其改为:

NVCCFLAGS += -D_FORCE_INLINES -ccbin=(CXX)−Xcompiler−fPIC(COMMON_FLAGS)


make matcaffe时报错

/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp: In function ‘void delete_solver(int, mxArray**, int, const mxArray**)’:
/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:208:3: warning: lambda expressions only available with -std=c++11 or -std=gnu++11 [enabled by default]
/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:208:4: error: no matching function for call to ‘remove_if(std::vector<boost::shared_ptr<caffe::Solver<float> > >::iterator, std::vector<boost::shared_ptr<caffe::Solver<float> > >::iterator, delete_solver(int, mxArray**, int, const mxArray**)::<lambda(const boost::shared_ptr<caffe::Solver<float> >&)>)’
/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:208:4: note: candidate is:
In file included from /usr/include/c++/4.7/algorithm:63:0,
from ./include/caffe/blob.hpp:4,
from ./include/caffe/caffe.hpp:7,
from /home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:18:
/usr/include/c++/4.7/bits/stl_algo.h:1166:5: note: template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)
/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:208:4: error: template argument for ‘template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)’ uses local type ‘delete_solver(int, mxArray**, int, const mxArray**)::<lambda(const boost::shared_ptr<caffe::Solver<float> >&)>’
/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:208:4: error:   trying to instantiate ‘template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)’
/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp: In function ‘void delete_net(int, mxArray**, int, const mxArray**)’:
/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:293:3: warning: lambda expressions only available with -std=c++11 or -std=gnu++11 [enabled by default]
/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:293:4: error: no matching function for call to ‘remove_if(std::vector<boost::shared_ptr<caffe::Net<float> > >::iterator, std::vector<boost::shared_ptr<caffe::Net<float> > >::iterator, delete_net(int, mxArray**, int, const mxArray**)::<lambda(const boost::shared_ptr<caffe::Net<float> >&)>)’
/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:293:4: note: candidate is:
In file included from /usr/include/c++/4.7/algorithm:63:0,
from ./include/caffe/blob.hpp:4,
from ./include/caffe/caffe.hpp:7,
from /home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:18:
/usr/include/c++/4.7/bits/stl_algo.h:1166:5: note: template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)
/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:293:4: error: template argument for ‘template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)’ uses local type ‘delete_net(int, mxArray**, int, const mxArray**)::<lambda(const boost::shared_ptr<caffe::Net<float> >&)>’
/home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:293:4: error:   trying to instantiate ‘template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)’

Makefile:518: recipe for target 'matlab/+caffe/private/caffe_.mexa64' failed
make: *** [matlab/+caffe/private/caffe_.mexa64] Error 255


修改Makefile里面的CXXFLAGS,添加CXXFLAGS += -std=c++11.然后重新编译就可以了

注意: 是添加不是修改

make mattest时报错:

Invalid MEX-file 'caffe/matlab/+caffe/private/caffe_.mexa64':
caffe/matlab/+caffe/private/caffe_.mexa64: undefined
symbol: _ZN2cv8imencodeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS_11_InputArrayERSt6vectorIhSaIhEERKSB_IiSaIiEE。

Error in caffe.set_mode_cpu (line 5)
caffe_('set_mode_cpu');

Error in caffe.run_tests (line 6)
caffe.set_mode_cpu();


有些说法是要执行如下命令:

export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libopencv_highgui.so.2.4:/usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.2.4:/usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4:/usr/lib/x86_64-linux-gnu/libstdc++.so.6:/usr/lib/x86_64-linux-gnu/libfreetype.so.6
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6


但是再次运行make
a088
mattest时会有新错误:

malloc: unknown:0: assertion botched
free: called with unallocated block argument
last command: (null)
Aborting...find: ‘bash’ terminated by signal 6


虽然最后还是能运行成功,但发现在运行bash指令时无法成功执行,纠结了好久发现是这里没有彻底解决问题,解决方法是:

将 libopencv_imgproc.so.2.4, libopencv_core.so.2.4, libopencv_highgui.so.2.4三个文件拷贝到/usr/local/MATLAB/R2016b/bin/glnxa64/中

$ sudo mv /usr/local/MATLAB/R2016b/bin/glnxa64/libopencv_imgproc.so.2.4 /usr/local/MATLAB/R2016b/bin/glnxa64/libopencv_imgproc.so.2.4.old
$ sudo cp /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.2.4 /usr/local/MATLAB/R2016b/bin/glnxa64/

$ sudo mv /usr/local/MATLAB/R2016b/bin/glnxa64/libopencv_core.so.2.4 /usr/local/MATLAB/R2016b/bin/glnxa64/libopencv_core.so.2.4.old
$ sudo cp /usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4 /usr/local/MATLAB/R2016b/bin/glnxa64/

$ sudo mv /usr/local/MATLAB/R2016b/bin/glnxa64/libopencv_highgui.so.2.4 /usr/local/MATLAB/R2016b/bin/glnxa64/libopencv_highgui.so.2.4.old
$ sudo cp /usr/lib/x86_64-linux-gnu/libopencv_highgui.so.2.4 /usr/local/MATLAB/R2016b/bin/glnxa64/


再执行

export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6


问题就解决啦,bash指令也没有问题啦
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  caffe