从github git 代码
https://github.com/rbgirshick/py-faster-rcnn
1.Requirements for Caffe
and pycaffe
根据一下2博文的编译caffe和pycaffe
ubuntu16.04+caffe+GPU Ubuntu16.04+CUDA8.0+caffe配置
http://blog.csdn.net/zhuiqiuk/article/details/54020688Caffe学习系列(13):数据可视化环境(python接口)配置
http://blog.csdn.net/zhuiqiuk/article/details/54093149
Installation (sufficient for the demo)
-
Clone the Faster R-CNN repository
# Make sure to clone with --recursive git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git
-
We'll call the directory that you cloned Faster R-CNN into
FRCN_ROOT
Ignore notes 1 and 2 if you followed step 1 above.
Note 1: If you didn't clone Faster R-CNN with the
--recursive
flag, then you'll need to manually clone thecaffe-fast-rcnn
submodule:git submodule update --init --recursive
Note 2: The
caffe-fast-rcnn
submodule needs to be on thefaster-rcnn
branch (or equivalent detached state). This will happen automatically if you followed step 1 instructions. -
Build the Cython modules
cd $FRCN_ROOT/lib make
-
Build Caffe and pycaffe
cd $FRCN_ROOT/caffe-fast-rcnn # Now follow the Caffe installation instructions here: # http://caffe.berkeleyvision.org/installation.html # If you're experienced with Caffe and have all of the requirements installed # and your Makefile.config in place, then simply do: make -j8 && make pycaffe
-
Download pre-computed Faster R-CNN detectors
cd $FRCN_ROOT ./data/scripts/fetch_faster_rcnn_models.sh
This will populate the
$FRCN_ROOT/data
folder withfaster_rcnn_models
. Seedata/README.md
for details.These models were trained on VOC 2007 trainval.
faster rcnn +cudnn V5
http://blog.csdn.net/u010733679/article/details/52221404
faster rcnn 代码默认是使用的cudnn v4, 但是为了体验最新的v5, 或者使用GTX1080 ,我们编译faster rcnn的时候就会报错:
In file included from ./include/caffe/util/cudnn.hpp:5:0,from ./include/caffe/util/device_alternate.hpp:40,from ./include/caffe/common.hpp:19,from src/caffe/data_reader.cpp:6:/usr/local/cuda/include/cudnn.h:799:27: note: declared herecudnnStatus_t CUDNNWINAPI cudnnSetPooling2dDescriptor(
为此提供2种解决方案:
(1)取自github @manipopopo
cd caffe-fast-rcnn
Git remote add caffe https://github.com/BVLC/caffe.git
git fetch caffe
git merge caffe/master
Remove self_.attr("phase") = static_cast<int>(this->phase_); from include/caffe/layers/python_layer.hpp after merging.
(2)手动修改文件,参考了卜居大神的博客 http://blog.csdn.net/kkk584520/article/details/51163564
方案1简单方便,但是当我们编译的是其他人修改过得源码,可能就会出错。方案2 步骤如下:
1. 用最新caffe源码的以下文件替换掉faster rcnn 的对应文件
include/caffe/layers/cudnn_relu_layer.hpp, src/caffe/layers/cudnn_relu_layer.cpp, src/caffe/layers/cudnn_relu_layer.cu
include/caffe/layers/cudnn_sigmoid_layer.hpp, src/caffe/layers/cudnn_sigmoid_layer.cpp, src/caffe/layers/cudnn_sigmoid_layer.cu
include/caffe/layers/cudnn_tanh_layer.hpp, src/caffe/layers/cudnn_tanh_layer.cpp, src/caffe/layers/cudnn_tanh_layer.cu
2. 用caffe源码中的这个文件替换掉faster rcnn 对应文件
include/caffe/util/cudnn.hpp
3. 将 faster rcnn 中的 src/caffe/layers/cudnn_conv_layer.cu 文件中的所有
cudnnConvolutionBackwardData_v3 函数名替换为 cudnnConvolutionBackwardData
cudnnConvolutionBackwardFilter_v3函数名替换为 cudnnConvolutionBackwardFilter
Demo
After successfully completing basic installation, you'll be ready to run the demo.
To run the demo
cd $FRCN_ROOT
./tools/demo.py
./tools/demo.py --net zf