编译caffe和matlab接口问题

来源:互联网 发布:飞秋for mac 编辑:程序博客网 时间:2024/05/19 17:02

原来已经在自己的电脑上安装过一次caffe,但这次在服务器上安装又出现了许多问题。

  1. make的时候报错,如下。

    AR -o .build_release/lib/libcaffe.aLD -o .build_release/lib/libcaffe.so.1.0.0/bin/ld: cannot find -lboost_system/bin/ld: cannot find -lboost_filesystem/bin/ld: cannot find -lboost_threadcollect2: error: ld returned 1 exit statusmake: *** [.build_release/lib/libcaffe.so.1.0.0] Error 1


明显原因没有找到包,于是在终端下输入

locate libboost_system

返回

[ymd@tjdp-4 caffe]$ locate libboost_thread/home/wzk/Downloads/Xilinx_Vivado_SDK_2015.4_1118_2/lib/lnx64.o/libboost_thread.so/home/wzk/Downloads/Xilinx_Vivado_SDK_2015.4_1118_2/lib/win64.o/libboost_thread.dll/home/ymd/matlab/bin/glnxa64/libboost_thread.so.1.49.0/opt/boost-1.59/lib/libboost_thread.a/opt/boost-1.59/lib/libboost_thread.so/opt/boost-1.59/lib/libboost_thread.so.1.59.0/usr/lib64/libboost_thread-mt.so.1.53.0......

在caffe的Makefile.config中找到

INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/includeLIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib

加上路径/opt/boost-1.59/lib/
这里写图片描述
剩下的包同理,没有找到的话参考其他教程。

再次make all,(之前最好make clean),就没问题了。

2.在配置matlab的caffe接口时,主要步骤参考caffe+MATLAB配置,但遇到一长串错误。

[ymd@tjdp-4 caffe]$ make matcaffeMEX matlab/+caffe/private/caffe_.cppBuilding with 'g++'.Warning: You are using gcc version '4.8.5-4)'. The version of gcc is not supported. The version currently supported with MEX is '4.7.x'. For a list of currently supported compilers see: http://www.mathworks.com/support/compilers/current_release.Warning: You are using gcc version '4.8.5'. The version of gcc is not supported. The version currently supported with MEX is '4.7.x'. For a list of currently supported compilers see: http://www.mathworks.com/support/compilers/current_release./home/ymd/caffe/matlab/+caffe/private/caffe_.cpp: In function \u2018void delete_solver(int, mxArray**, int, const mxArray**)\u2019:/home/ymd/caffe/matlab/+caffe/private/caffe_.cpp:208:3: warning: lambda expressions only available with -std=c++11 or -std=gnu++11 [enabled by default]   }), solvers_.end());   ^/home/ymd/caffe/matlab/+caffe/private/caffe_.cpp:208:4: error: no matching function for call to \u2018remove_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**)::__lambda0)\u2019   }), solvers_.end());    ^/home/ymd/caffe/matlab/+caffe/private/caffe_.cpp:208:4: note: candidate is:In file included from /usr/include/c++/4.8.2/algorithm:62:0,                 from ./include/caffe/blob.hpp:4,                 from ./include/caffe/caffe.hpp:7,                 from /home/ymd/caffe/matlab/+caffe/private/caffe_.cpp:18:/usr/include/c++/4.8.2/bits/stl_algo.h:1134:5: note: template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)     remove_if(_ForwardIterator __first, _ForwardIterator __last,     ^/usr/include/c++/4.8.2/bits/stl_algo.h:1134:5: note:   template argument deduction/substitution failed:/home/ymd/caffe/matlab/+caffe/private/caffe_.cpp: In substitution of \u2018template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate) [with _FIter = __gnu_cxx::__normal_iterator<boost::shared_ptr<caffe::Solver<float> >*, std::vector<boost::shared_ptr<caffe::Solver<float> > > >; _Predicate = delete_solver(int, mxArray**, int, const mxArray**)::__lambda0]\u2019:/home/ymd/caffe/matlab/+caffe/private/caffe_.cpp:208:4:   required from here/home/ymd/caffe/matlab/+caffe/private/caffe_.cpp:208:4: error: template argument for \u2018template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)\u2019 uses local type \u2018delete_solver(int, mxArray**, int, const mxArray**)::__lambda0\u2019   }), solvers_.end());    ^/home/ymd/caffe/matlab/+caffe/private/caffe_.cpp:208:4: error:   trying to instantiate \u2018template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)\u2019/home/ymd/caffe/matlab/+caffe/private/caffe_.cpp: In function \u2018void delete_net(int, mxArray**, int, const mxArray**)\u2019:/home/ymd/caffe/matlab/+caffe/private/caffe_.cpp:293:3: warning: lambda expressions only available with -std=c++11 or -std=gnu++11 [enabled by default]   }), nets_.end());   ^/home/ymd/caffe/matlab/+caffe/private/caffe_.cpp:293:4: error: no matching function for call to \u2018remove_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**)::__lambda1)\u2019   }), nets_.end());    ^/home/ymd/caffe/matlab/+caffe/private/caffe_.cpp:293:4: note: candidate is:In file included from /usr/include/c++/4.8.2/algorithm:62:0,                 from ./include/caffe/blob.hpp:4,                 from ./include/caffe/caffe.hpp:7,                 from /home/ymd/caffe/matlab/+caffe/private/caffe_.cpp:18:/usr/include/c++/4.8.2/bits/stl_algo.h:1134:5: note: template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)     remove_if(_ForwardIterator __first, _ForwardIterator __last,     ^/usr/include/c++/4.8.2/bits/stl_algo.h:1134:5: note:   template argument deduction/substitution failed:/home/ymd/caffe/matlab/+caffe/private/caffe_.cpp: In substitution of \u2018template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate) [with _FIter = __gnu_cxx::__normal_iterator<boost::shared_ptr<caffe::Net<float> >*, std::vector<boost::shared_ptr<caffe::Net<float> > > >; _Predicate = delete_net(int, mxArray**, int, const mxArray**)::__lambda1]\u2019:/home/ymd/caffe/matlab/+caffe/private/caffe_.cpp:293:4:   required from here/home/ymd/caffe/matlab/+caffe/private/caffe_.cpp:293:4: error: template argument for \u2018template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)\u2019 uses local type \u2018delete_net(int, mxArray**, int, const mxArray**)::__lambda1\u2019   }), nets_.end());    ^/home/ymd/caffe/matlab/+caffe/private/caffe_.cpp:293:4: error:   trying to instantiate \u2018template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)\u2019make: *** [matlab/+caffe/private/caffe_.mexa64] Error 255

在http://www.caffecn.cn/?/question/1145的评论一楼给出了解决方法,在Makefile.config添加CXXFLAGS += -std=c++11 再编译下就好了.

[ymd@tjdp-4 caffe]$ make matcaffeMEX matlab/+caffe/private/caffe_.cppBuilding with 'g++'.Warning: You are using gcc version '4.8.5-4)'. The version of gcc is not supported. The version currently supported with MEX is '4.7.x'. For a list of currently supported compilers see: http://www.mathworks.com/support/compilers/current_release.Warning: You are using gcc version '4.8.5'. The version of gcc is not supported. The version currently supported with MEX is '4.7.x'. For a list of currently supported compilers see: http://www.mathworks.com/support/compilers/current_release.MEX completed successfully.

successfully!!!!!!!!!!!

在零零碎碎找了一大堆资料后并且安装成功后,发现了一个安装大礼包:配好caffe后,编译MATLAB接口。

参考

[1]http://blog.csdn.net/zjq2008wd/article/details/17450033
[2]http://www.caffecn.cn/?/question/1145
[3]http://blog.csdn.net/fangbinwei93/article/details/52865461
[4]http://blog.csdn.net/weiqi_fan/article/details/71023222
[5]https://yq.aliyun.com/articles/5748
[6]http://blog.csdn.net/u012746763/article/details/50419153
[7]http://caffe.berkeleyvision.org/tutorial/interfaces.html(官方文档)
[8]http://caffe.berkeleyvision.org/installation.html(官方文档)