1、Clone the faster r-cnn 注意参数–recursive(递归),要不caffe-fast-rcnn文件夹就是空的,看看git的目录就知道为什么了。另外假设你下载下来的文件名字叫py-faster-rcnn,接下来所有的操作都是在这个文件夹下面进行,所以请记住这个名字。
git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git
发现这一步必须严格执行 否则下载的代码是不一样的,和git版本管理有关
尤其由于faster-rcnn版本过早 导致的cudnn版本问题成不可解,规避方法如下
配置完成后,下面进行编译。直接编译会出现编译错误,这是因为faster-rcnn默认的caffe支持的cudnn版本是V4,而想用1080Ti显卡,必须使用cuda7.5+cudnn5.0以上版本,因此编译caffe会出现版本不兼容而导致的函数参数不对应的错误。这种情况参考博文:http://blog.csdn.net/u010733679/article/details/52221404, 笔者是用的手动修改的方式,下载最新的caffe:https://github.com/BVLC/caffe, 用最新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 用caffe源码中的这个文件替换掉faster rcnn 对应文件 include/caffe/util/cudnn.hpp 将 faster rcnn 中的 src/caffe/layers/cudnn_conv_layer.cu 文件中的所有 cudnnConvolutionBackwardData_v3 函数名替换为 cudnnConvolutionBackwardData cudnnConvolutionBackwardFilter_v3函数名替换为 cudnnConvolutionBackwardFilter
使用beyond compare 对比版本master 与rcnn版方便完成
2,caffe makefile.config 修改:
合理安装opcv 3 ,cuda ,cudnn ,hdf5,python
对相关配置项都需要修改
USE_CUDNN := 1
USE_LMDB := 1
OPENCV_VERSION := 3
CUDA_DIR := /usr/local/cuda
//1cuda 9.0 要注销20
CUDA_ARCH :=
#-gencode arch=compute_20,code=sm_20 \
-gencode arch=compute_20,code=sm_21 \
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_50,code=compute_50
//python 部分
PYTHON_LIBRARIES := boost_python3 python3.6m
ANACONDA_HOME := /home/caocheng/anaconda3
PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
$(ANACONDA_HOME)/include/python3.6m \
$(ANACONDA_HOME)/lib/python3.6/site-packages/numpy/core/include
//环境数据库等 利用conda配置
ANACONDA_HOME := $(HOME)/anaconda3
WITH_PYTHON_LAYER := 1
# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/lib/x86_64-linux-gnu/hdf5/serial/include\
/home/caocheng/anaconda3/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib \
/home/caocheng/anaconda3/lib /usr/lib/x86_64-linux-gnu/hdf5/serial
添加的配置库
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/hdf5/serial/
最后统一添加的库
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
3,test 编译
nn/src/caffe/test/test_smooth_L1_loss_layer.cpp
屏蔽冲突 //#include "caffe/vision_layers.hpp"
4,在sudosu 环境下使用make runtest -8 更合适 否则报错增多
报错汇总:
1,
/usr/local/lib/libopencv_imgcodecs.so.3.0.0:对‘TIFFClose@LIBTIFF_4.0’未定义的引用 /usr/local/lib/libopencv_imgcodecs.so.3.0.0:对‘TIFFRGBAImageOK@LIBTIFF_4.0’未定义的引用 /usr/local/lib/libopencv_imgcodecs.so.3.0.0:对‘TIFFReadRGBAStrip@LIBTIFF_4.0’未定义的引用 --------------------- 本文来自 mdjxy63 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/mdjxy63/article/details/74783817?utm_source=copycollect2: error: ld returned 1 exit status make[2]: *** [DisplayImage] 错误 1 make[1]: *** [CMakeFiles/DisplayImage.dir/all] 错误 2 make: *** [all] 错误 2 Answer1: 参考这个链接:https://serverfault.com/questions/696631/libcurl-so-4-no-version-information-available 原因是软连接没做好:
sudo ln -fs /usr/lib/libcurl.so.4 /usr/local/lib/
2,
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
python/caffe/_caffe.cpp:11:31: fatal error: numpy/arrayobject.h: 没有那个文件或目录
compilation terminated.
Makefile:489: recipe for target 'python/caffe/_caffe.so' failed
make: *** [python/caffe/_caffe.so] Error 1
解决:sudo apt-get install python-numpy
3, HDF5 问题
The HDF5 header files used to compile this application do not match
the version used by the HDF5 library to which this application is linked.
Data corruption or segmentation faults may occur if the application continues.
This can happen when an application was compiled by one version of HDF5 but
linked with a different version of static or shared HDF5 library.
You should recompile the application or check your shared library related
settings such as 'LD_LIBRARY_PATH'.
You can, at your own risk, disable this warning by setting the environment
variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'.
Setting it to 2 or higher will suppress the warning messages totally.
Headers are 1.10.0, library is 1.10.2
解决需要 安装正确的hdf5 文件 ,并在配置cofig中加入正确的 路径 ,我没有加入include hdf5 路径所以报错使用的也不知道是那里的hdf5版本