编译caffe和matlab接口问题

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

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

    AR -o .build_release/lib/libcaffe.a
    LD -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_thread
    collect2: error: ld returned 1 exit status
    make: *** [.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/include
LIBRARY_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 matcaffe
MEX matlab/+caffe/private/caffe_.cpp
Building 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)\u2019

make: *** [matlab/+caffe/private/caffe_.mexa64] Error 255

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

[ymd@tjdp-4 caffe]$ make matcaffe
MEX matlab/+caffe/private/caffe_.cpp
Building 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(官方文档)

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值