Ubuntu16.04下环境配置Caffe

前端之家收集整理的这篇文章主要介绍了Ubuntu16.04下环境配置Caffe前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

caffe装matlab接口报错: recipe for target ‘matlab/+caffe/private/caffe_.mexa64’ Failed

MEX matlab/+caffe/private/caffe_.cpp
Building with 'g++'.
Warning: You are using gcc version '5.4.0'. 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 '5.4.0-6ubuntu1~16.04.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.
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp: In function ‘void delete_solver(int,mxArray**,int,const mxArray**)’:
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp:208:3: warning: lambda expressions only available with -std=c++11 or -std=gnu++11
   }),solvers_.end());
   ^
/home/mcs/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,const mxArray**)::<lambda(const boost::shared_ptr<caffe::Solver<float> >&)>)’
   }),solvers_.end());
    ^
In file included from /usr/include/c++/5/algorithm:62:0,from ./include/caffe/blob.hpp:4,from ./include/caffe/caffe.hpp:7,from /home/mcs/caffe/matlab/+caffe/private/caffe_.cpp:18:
/usr/include/c++/5/bits/stl_algo.h:926:5: note: candidate: template<class _FIter,class _Predicate> _FIter std::remove_if(_FIter,_FIter,_Predicate)
     remove_if(_ForwardIterator __first,_ForwardIterator __last,^
/usr/include/c++/5/bits/stl_algo.h:926:5: note:   template argument deduction/substitution Failed:
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp: In substitution of ‘template<class _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,const mxArray**)::<lambda(const boost::shared_ptr<caffe::Solver<float> >&)>]’:
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp:208:4:   required from here
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp:208:4: error: template argument for ‘template<class _FIter,_Predicate)’ uses local type ‘delete_solver(int,const mxArray**)::<lambda(const boost::shared_ptr<caffe::Solver<float> >&)>’
   }),solvers_.end());
    ^
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp:208:4: error:   trying to instantiate ‘template<class _FIter,_Predicate)’
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp: In function ‘void delete_net(int,const mxArray**)’:
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp:293:3: warning: lambda expressions only available with -std=c++11 or -std=gnu++11
   }),nets_.end());
   ^
/home/mcs/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,const mxArray**)::<lambda(const boost::shared_ptr<caffe::Net<float> >&)>)’
   }),nets_.end());
    ^
In file included from /usr/include/c++/5/algorithm:62:0,_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,const mxArray**)::<lambda(const boost::shared_ptr<caffe::Net<float> >&)>]’:
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp:293:4:   required from here
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp:293:4: error: template argument for ‘template<class _FIter,_Predicate)’ uses local type ‘delete_net(int,const mxArray**)::<lambda(const boost::shared_ptr<caffe::Net<float> >&)>’
   }),nets_.end());
    ^
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp:293:4: error:   trying to instantiate ‘template<class _FIter,_Predicate)’

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

一开始以为是warning中说明的问题,即gcc版本不兼容导致的,Ubuntu 16.04默认gcc版本是5.4,后来换成gcc-4.7,caffe却无法编译了,主要问题出在protobuf中。后来又尝试了使用gcc-5编译caffe,然后换成gcc-4.7,编译matcaffe时,出现另一个错误,问题好像还是protobuf编译出错。之后又尝试了从源码安装protobuf,想换高版本的MATLAB,总之坑了好久,都没解决问题。

http://www.caffecn.cn/?/question/1113中,终于找到解决方案:

修改makefile里面的CXXFLAGS,添加CXXFLAGS += -std=c++11.然后重新编译就可以了。 即:在那一句话下面添加,如下这样 CXXFLAGS += -MMD -MP CXXFLAGS += -std=c++11

原文链接:https://www.f2er.com/ubuntu/354007.html

猜你在找的Ubuntu相关文章