本文主要是介绍r-cnn+caffe-0.999+GTX1080,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
R-CNN在GTX1080上运行
按照作者rbgirshick的 github上安装顺序进行安装。
PS:这里只能安装caffe-0.999,下载地址上面也有。
1、caffe-0.999的安装
安装的依赖库之类的在以前的版本中安装过了,直接修改Makefile.config文件即可。
参照以前安装版本的caffe的Makefile.config文件修改即可。
make all -j16
出现错误:
undefined reference tocv::imencode(cv::String const&, cv::_InputArray const&, std::vector >&, std::vector > const&)'
.build_release/lib/libcaffe-nv.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
collect2: error: ld returned 1 exit status
make: *** [.build_release/tools/upgrade_net_proto_text.bin] Error 1
解决方法:
change Makefile:
LIBRARIES += glog gflags protobuf leveldb snappy \
lmdb boost_system hdf5_hl hdf5 m \
opencv_core opencv_highgui opencv_imgproc
add :opencv_imgcodecs solve my problem
make runtest -j16
出现错误:
[ FAILED ] 7 tests, listed below:
[ FAILED ] MathFunctionsTest/0.TestSgnbitCPU, where TypeParam = float
[ FAILED ] PowerLayerTest/0.TestPowerGradientShiftZero, where TypeParam = caffe::FloatCPU
[ FAILED ] PowerLayerTest/1.TestPowerGradientShiftZero, where TypeParam = caffe::DoubleCPU
[ FAILED ] PowerLayerTest/1.TestPowerGradient, where TypeParam = caffe::DoubleCPU
[ FAILED ] PowerLayerTest/2.TestPowerGradientShiftZero, where TypeParam = caffe::FloatGPU
[ FAILED ] PowerLayerTest/3.TestPowerGradientShiftZero, where TypeParam = caffe::DoubleGPU
[ FAILED ] PowerLayerTest/3.TestPowerGradient, where TypeParam = caffe::DoubleGPU
MathFunctionsTest解决方法:https://github.com/BVLC/caffe/pull/1264
在修改https://github.com/BVLC/caffe/pull/1264/files 中,共需要修改三个文件,我对比caffe-0.999版本之后,发现只需要修改其中的两个,也就是:
include/caffe/util/math_functions.hpp
src/caffe/util/math_functions.cpp
按照上面显示的修改即可。
PowerLayerTest解决方法:https://github.com/BVLC/caffe/pull/1840
make matcaffe -j16
出现错误:
/usr/local/MATLAB/R2014a/bin/mex matlab/caffe/matcaffe.cpp build/lib/libcaffe.a \
CXXFLAGS="\$CXXFLAGS -pthread -fPIC -DNDEBUG -O2 -I/usr/local/include/python2.7 -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/usr/local/include -Ibuild/src -I./src -I./include -I/usr/local/cuda/include -Wall" \
CXXLIBS="\$CXXLIBS -L/usr/local/lib -L/usr/local/lib -L/usr/lib -L/usr/local/cuda/lib64 -L/usr/local/cuda/lib -lcudart -lcublas -lcurand -lpthread -lglog -lprotobuf -lleveldb -lsnappy -lboost_system -lhdf5_hl -lhdf5 -lopencv_core -lopencv_highgui -lopencv_imgproc -lcblas -latlas" -o matlab/caffe/caffe.mexa64
Unknown MEX argument '-o'.
make: *** [matlab/caffe/caffe.mexa64] Error 255
解决方法:
参考https://github.com/BVLC/caffe/pull/696
make pycaffe -j16
出现错误:
/usr/bin/g++ -shared -o python/caffe/_caffe.so python/caffe/_caffe.cpp \build/lib/libcaffe.a -pthread -fPIC -DNDEBUG -O2 -I/usr/local/include/python2.7 - I/usr/local/lib/python2.7/dist- packages/numpy/core/include -I/usr/local/include -Ibuild/src -I./src -I./include -I/usr/local/cuda/include -L/usr/local/lib -L/usr/local/lib -L/usr/lib -L/usr/local/cuda/lib64 - L/usr/local/cuda/lib -lcudart -lcublas -lcurand -lpthread -lglog -lprotobuf -lleveldb -lsnappy -lboost_system -lhdf5_hl -lhdf5 -lopencv_core -lopencv_highgui -lopencv_imgproc -lcblas -latlas - lboost_python -lpython2.7In file included from /usr/include/boost/python/detail/prefix.hpp:13:0,from /usr/include/boost/python/args.hpp:8,from /usr/include/boost/python.hpp:11,from python/caffe/_caffe.cpp:8:/usr/include/boost/python/detail/wrap_python.hpp:50:23: fatal error: pyconfig.h: No such file or directorycompilation terminated.make: *** [python/caffe/_caffe.so] Error 1
解决方法:
make clean
export CPLUS_INCLUDE_PATH=/usr/include/python2.7
make all -j16
make test -j16
make runtest -j16
make matcaffe -j16
make pycaffe -j16
最终还是会出现
YOU HAVE 2 DISABLED TESTS
可以忽略:https://github.com/BVLC/caffe/issues/982
最终查看python接口是否编译成功:
进入python环境,进行import操作
# python
>>> import caffe
如果没有提示错误,则编译成功。
2、R-CNN的安装
按照作者github上指示正常安装,但是在创建链接时,出现错误,我的链接总是显示已损坏。
解决方法:
参考:https://ubuntuforums.org/showthread.php?t=1062535
cd rcnn_series
ln -sf "$PWD"/caffe "$PWD"/rcnn/external/caffe
链接创建成功。
运行
key = caffe('get_init_key')
出现错误:
Invalid MEX-file ‘**/caffe.mexa64’
/usr/local/MATLAB/R2014a/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: version GLIBCXX_3.4.21 not found (required by **/caffe.mexa64)
解决方法:
参考:Invalid MEX-file: caffe.mexa64 的解决方案
# ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/local/MATLAB/R2014a/bin/glnxa64/libstdc++.so.6
运行后出现有一个错误 ==。:
Invalid MEX-file
'/home/zhou/rcnn_series/rcnn/external/caffe/matlab/caffe/caffe_.mexa64':
/home/zhou/rcnn_series/rcnn/external/caffe/matlab/caffe/caffe_.mexa64: undefined symbol:
_ZNK6google8protobuf7MessageGETxxxxxx(后面的信息不记得了)
查看matlab的依赖库和caffe的不同之处,参考
MATLAB2013a update and mexopencv failing #62
MATLAB compatibility #9:
在终端输入:
ldd /home/zhou/rcnn_series/rcnn/external/caffe/matlab/caffe/caffe_.mexa64
在matlab窗口输入:
!ldd /home/zhou/rcnn_series/rcnn/external/caffe/matlab/caffe/caffe_.mexa64
经过google之后发现是libprotobuf.so.8存在问题。
解决方法:
关闭matlab,在终端输入:
sudo rm -f /usr/local/MATLAB/R2014a/bin/glnxa64/libprotobuf.so.8
sudo ln -sf /usr/local/lib/libprotobuf.so.8 /usr/local/MATLAB/R2014a/bin/glnxa64/libprotobuf.so.8
重新在rcnn目录下打开matlab,发现运行成功(key(‘get_init_key’)=-2)!!!
下载实验所需要数据:r-cnn-release1-data.tgz 和 r-cnn-release1-selective-search.tgz
然后直接在matlab中输入rcnn_demo,即可实现目标检测啦!
由于目前所做研究跟rcnn有关,所以需要实现一下,在此记录。
这篇关于r-cnn+caffe-0.999+GTX1080的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!