ubuntu14.04编译和运行 fast rcnn
CuDNN兼容性问题造成的fast rcnn编译运行失败和出现浮点数例外(核心已转储)
1.第一部分:git官网的fast-rcnn源码
终端输入:
cd/home/**(您服务器的名字)
gitclone --recursive https://github.com/rbgirshick/fast-rcnn.git
下载完成后再home/**(您服务器的名字)下有
2. 第二部分:Python安装包cython,python-opencv,easydict
终端输入:
sudo apt-get install python-pip
sudo pip install cython
sudo apt-get install python-opencv
sudo pip install easydict
3. 第三部分:生成Cython模块
终端输入:
cd /home/**(您服务器的名字)/fast-rcnn/lib
make
4. 第四部分:安装atlas
终端输入:
sudo apt-get installlibatlas-base-dev
5. 第五部分:生成Caffe和pycaffe
进入caffe-fast-rcnn 目录:
Sudo mkdir build
Cd build
Cmake ..
Cd ..
Sudomake –j8 &&make pycaffe
Makematcaffe
Make runtest
如果你按照网上的方法配置他自带的caffe,就会出现上图的错误:浮点数例外(核心已转储)
原因是因为fastrcnn 自带的caffe是很早的版本,cudnn只有4.0不支持我们现在的cudnn 5.1,所以两种方法:1.对cudnn降价到4.0 ,请自行解决吧!2.我用我编译好的microsoft的caffe-master 来替带自带的caffe-fast-rcnn,然后把名字改成相同,这样再编译就不会出错误。接着如果你按照第二个方法做的话,会遇到很多错误。
我讲下我遇到的错误和解决方法,比如像cv::imread() cv::indecode()等等之类的opencv问题,解决办法:在caffe-fast-rcnn的Makefile目录里的第166行加入opencv_imgcodecs,如图所示:
在阴影部分的后面加入opencv_imgcodecs。
运行demo.py文件不说了。
接着在运行fastrcnn/tools/train_net.py时会出现错误:
在网络初始化到loss_bbox层时会出现smoothL1loss.cpperror :bottom.size=4(3vs.4) If weightsare used, must specify both inside and outside weights之类错误!
解决办法:找到SmoothL1loss.cpp,找到出错误的那部分,如图:
看到has_weights=(bottom.size()>=3);把它改成has_weights=(bottom.size()==3);然后下面的if语句用//注释掉。接着还要改,看到下面的这几行代码:
CHECK_EQ(bottom[0]->channels(),bottom[3]->channels());
CHECK_EQ(bottom[0]->height(), bottom[3]->height());
CHECK_EQ(bottom[0]->width(), bottom[3]->width());
这三行,也要用//注释掉。Ok!!!!!
再重新编译!!!!make clean make -j8
6.cp caffe里的cudnn.hpp ./include/caffe/util/cudnn.hpp
7.将./src/caffe/layer里所有以cudnn开头的文件,如cudnn_xxx_layer.cu,cudnn_xxx_layer.cpp
都替换成最新版的caffe里的相应的同名文件。
8.
重点问题:如果出现以下问题:
check failed error ==cudaSuccess(77 vs .0)an illegal memory access was encountered
check failed data_ *** check failure stacktrace:****
那是因为cudnn的问题,fastrcnn 只支持cudnn4 ,可以用以下方法解决:
cdcaffe-fast-rcnn
git init
git remote add caffehttps://github.com/BVLC/caffe.git
git fetch caffe
git clean -d-fx
git merge caffe/master
merge 后删除 include/caffe/layers/python_layer.hpp 中的 self_.attr("phase")= static_cast<int>(this->phase_);
9.
.在caffe中如何加入新的一层,就如如何加入normalize层,首先去找到caffe-ssd,因为这个caffe有normalize层,我们首先把normalize.cpp normalize.cu normalize.hpp复制到相应的位置,然后找到src/caffe/proto/caffe.proto,加入normalizeParameter层的声明(复制caffe-ssd)和下面加上定义(f复制caffe-ssd):message NormalizeParameter{
参数
}
网址:http://blog.****.net/shuzfan/article/details/51322976
10.运行demo.py和训练,请看网址:http://blog.****.net/u014696921/article/details/52453947