准备
请参考 深度学习:Ubuntu16.04+双TitanX+CUDA8.0+CUDNN5.1+Caffe 搭建起深度学习基础平台
安装
- github address Fater RCNN
git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git
- Faster R-CNN 并不支持CUDNN5.1 所以需要合并Caffe来支持
cd caffe-fast-rcnn
git remote add caffe https://github.com/BVLC/caffe.git
git fetch caffe
git merge -X theirs caffe/master
然后删除 self_.attr("phase") = static_cast<int>(this->phase_);
从 include/caffe/layers/python_layer.hpp
中,当合并结束后
- Build the Cython modules
cd $FRCN_ROOT/lib
make
- 修改Makfile.config
USE_CUDNN := 1 (可选)
USE_OPENCV := 1 (可选)
OPENCV_VERSION := 3 (如果打开了USE_OPENCV,而且opencv版本为3时)
PYTHON_INCLUDE := /usr/include/python2.7 /usr/lib/python2.7/dist-packages/numpy/core/include
WITH_PYTHON_LAYER := 1
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial /usr/local/share/OpenCV/3rdparty/lib
- 修改Makfile
将下面这一行:
NVCCFLAGS += -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
替换为:
NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
当使用opencv3 出现错误 imread,imencode,imdecode
或者 VideoCapture
时,编辑Makefile
:
LIBRARIES += glog gflags protobuf leveldb snappy \
lmdb boost_system boost_filesystem hdf5_hl hdf5 m \
opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs opencv_videoio
- 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
一些可能的错误
- src/caffe/test/test_smooth_L1_loss_layer.cpp:11:35: fatal error: caffe/vision_layers.hpp: No such file or directory
直接删除这一行就好了