安装:
事先安装好anaconda2,opencv3.1,cuda8.0,cudnn5.1,参见点击打开链接
安装tensorflow:
pip install tensorflow_gpu-1.0.1-cp27-none-linux_x86_64.whl
安装faster-cnn:
1.Clone the Faster R-CNN repository:
git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git
2.Build the Cython modules:
cd $FRCN_ROOT/lib make
3.Build Caffe and pycaffe:
cd $FRCN_ROOT/caffe-fast-rcnn
make -j8 && make pycaffe
makefile 见点击打开链接
makefile.config文件的修改如下:
# cuDNN acceleration switch (uncomment to build with cuDNN).
USE_CUDNN := 1
# Uncomment if you're using OpenCV 3
OPENCV_VERSION := 3
# NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.h and numpy/arrayobject.h.
# PYTHON_INCLUDE := /usr/include/python2.7 \
#/usr/lib/python2.7/dist-packages/numpy/core/include
# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location, sometimes it's in root.
ANACONDA_HOME := $(HOME)/Softwares/anaconda
PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
$(ANACONDA_HOME)/include/python2.7 \
$(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include \
# PYTHON_LIB := /usr/lib
PYTHON_LIB := $(ANACONDA_HOME)/lib
# Uncomment to support layers written in Python (will link against Python libs)
WITH_PYTHON_LAYER := 1
# Whatever else you find you need goes here.
#INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
#LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
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
问题:
1.与cudnn有关
rbgirshick的py-faster-rcnn实现,因为其cudnn实现为旧版本的实现,与系统所安装的cudnn的版本不一致。
解决办法:
1 .将./include/caffe/util/cudnn.hpp 换成最新版的caffe里的cudnn的实现,即相应的cudnn.hpp.
2. 将./include/caffe/layers里的,所有以cudnn开头的文件,例如cudnn_conv_layer.hpp。 都替换成最新版的caffe里的相应的同名文件。
3.将./src/caffe/layer里的,所有以cudnn开头的文件,例如cudnn_lrn_layer.cu,cudnn_pooling_layer.cpp,cudnn_sigmoid_layer.cu。
都替换成最新版的caffe里的相应的同名文件。
2.与google::protobuf有关
undefined reference to `google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)'
解决办法:
下载protobuf-2.5.0手动编译安装,然后讲google这个文件夹拷贝到site-packages下面
3. /usr/bin/ld: cannot find -lxxx
意思是编译过程找不到对应库文件。其中,-lxxx表示链接库文件 libxxx.so。
解决办法:apt-get install libxxx-dev
关于数据集:
wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtrainval_06-Nov-2007.tar wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtest_06-Nov-2007.tar wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCdevkit_08-Jun-2007.tar关于训练;
python ./tools/train_net.py --gpu 0 --solver models/pascal_voc/VGG16/fast_rcnn/solver.prototxt --iters 50000 --cfg experiments/cfgs/faster_rcnn_end2end.yml --imdb voc_2007_trainval