在caffe环境下搭建自己的Faster RCNN

本文记录了在Caffe环境中搭建Faster R-CNN的步骤,包括安装依赖、修改setup.py、调整Makefile.config以及解决由于Python版本、cudnn版本不匹配导致的编译问题。通过替换旧版文件为Caffe最新版本的对应文件成功解决问题。
摘要由CSDN通过智能技术生成

参考链接:https://blog.csdn.net/sinat_30071459/article/details/51332084

                      https://blog.csdn.net/u011070171/article/details/52399317

1、在命令窗口pip需要的cython, python-opencv,easydict

pip install cython  
pip install easydict  
apt-get install python-opencv  

2、从github上下载需要的源码py-faster-rcnn

git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git 

3、进入py-faster-rcnn/lib,执行make

执行make的时候出现问题:原因是使用的是Python3.5,需要将setup.py中的iteriterms改成items

python setup.py build_ext --inplace
Traceback (most recent call last):
  File "setup.py", line 58, in <module>
    CUDA = locate_cuda()
  File "setup.py", line 53, in locate_cuda
    for k, v in cudaconfig.iteritems():
AttributeError: 'dict' object has no attribute 'iteritems'
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 1

4、这一大步坑很多很多,搞了好久才搞通

进入py-faster-rcnn\caffe-fast-rcnn,执行 cp Makefile.config.example Makefile.config4、修改makefile.config文件,需要修改的主要有好几个个地方。如果安装了MKL数学计算库就把“BLAS := atlas”改为“BLAS := mkl”。

WITH_PYTHON_LAYER := 1  
USE_CUDNN := 1 
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial

进行编译:

make -j8 && make pycaffe 

(1)编译后出现如下错误:出现错误的原因是编译依赖了GPU的一些库,在配置文件中解除注释 CPU_ONLY := 1就行了

./include/caffe/util/device_alternate.hpp:34:23: fatal error: cublas_v2.h: 没有那个文件或目录

错误原因分析:

源代码执行的环境要求cudnn的版本为4.0,经过检查版本,我的cudnn版本为6.0.21,版本不匹配。解决办法经查找有:1).将/py-faster-rcnn/caffe-fast-rcnn/include/caffe/util/cudnn.hpp 换成最新版的caffe里的cudnn的实现,即相应的cudnn.hpp.
2).将/py-faster-rcnn/caffe-fast-rcnn/src/caffe/layer里的,所有以cudnn开头的文件,例如cudnn_lrn_layer.cu,cudnn_pooling_layer.cpp,cudnn_sigmoid_layer.cu。

都替换成最新版的caffe里的相应的同名文件。(我最后采用了这个方法)

按下述方法进行了修改依然报错,在评论里看到另一种方法:

cd caffe-fast-rcnn
git remote add caffe https://github.com/BVLC/caffe.git
git fetch caffe
git merge -X theirs caffe/master
其实中间还遇到了各种各样的错误,总之最后弄出来真的有点心塞塞

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值