环境:jetson tx2 + jetpack 3.2(cuda9.0+cudnn5)
第一步:下载源码
git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git
第二步:复制makefile,编译过caffe的肯定很熟悉
cp Makefile.config.example Makefile.config
第三步:修改Makefile和Makefile.config里面的内容,和编译caffe时候很像
Makefile:
修改为:
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial
Makefile.config:
修改成为以下内容
# cuDNN acceleration switch (uncomment to build with cuDNN).
USE_CUDNN := 1
# Uncomment if you're using OpenCV 3
OPENCV_VERSION := 3
# Uncomment to support layers written in Python (will link against Python libs)
WITH_PYTHON_LAYER := 1
# We need to be able to find Python.h and numpy/arrayobject.h.
PYTHON_INCLUDE := /usr/include/python2.7 \
/usr/local/lib/python2.7/dist-packages/numpy/core/include
# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /aarch64-linux-gnu/hdf5/serial
第四步:进入py-faster-rcnn/lib目录下
make
第五步:JetPack3.2 的cudnn版本新需要替换一些文件
1)找到caffe中的
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
include/caffe/util/cudnn.hpp
替换掉faster-rcnn对应的文件
2)将 faster rcnn 中的 src/caffe/layers/cudnn_conv_layer.cu 文件中的两个函数
cudnnConvolutionBackwardData_v3 函数名替换为 cudnnConvolutionBackwardData
cudnnConvolutionBackwardFilter_v3函数名替换为 cudnnConvolutionBackwardFilter
第六步:编译
caffe-fast-rcnn目录下:
make -j8 && make pycaffe
第七步:下载模型
1)在终端下载:
cd $FRCN_ROOT
./data/scripts/fetch_faster_rcnn_models.sh
速度很慢,会出现time out
2)使用aria2+uget+firefox的方法下载百度云上的模型文件
sudo add-apt-repository ppa:plushuang-tw/uget-stable
sudo add-apt-repository ppa:t-tujikawa/ppa
sudo apt-get install aria2
sudo apt-get install uget
将firefox的百度云文件导出为aria2文件,在uget里下载即可(类似迅雷链接)
下载前需要配置一下uge,很简单网上有教程
下面是模型的aria2的文本,复制到uget新建下载任务就可
https://d.pcs.baidu.com/file/7e9db88ca720b26f069e934b5a974d3e?fid=3106987140-250528-1079755257952860&dstime=1532435155&rt=sh&sign=FDtAERV-DCb740ccc5511e5e8fedcff06b081203-1%2BBYMqQg72ypDN%2B2jWPmL2Smdb0%3D&expires=8h&chkv=1&chkbd=0&chkpc=&dp-logid=139394917580929411&dp-callid=0&r=252466376
header=User-Agent: netdisk;5.3.4.5;PC;PC-Windows;5.1.2600;WindowsBaiduYunGuanJia
header=Referer: https://pan.baidu.com/disk/home
header=Cookie: pcsett=1532521194-dab94490173bbdb1a4df6dc4745cbaef
out="faster_rcnn_models.tar"
下载完成后解压到data目录下
第八步:运行demo
./data/scripts/fetch_faster_rcnn_models.sh
一共十张照片
遇到的一些问题:
make: * [.build_release/examples/cifar10/convert_cifar_data.bin] 错误
make: *** [.build_release/tools/caffe.bin] Error 1
1)make clean 重新编译
2)delete /usr/lib/libcaffe.so文件
[.build_release/tools/extract_features.bin] Error 1
看看makefile.config里面是否用到了anaconda,若有注释掉