使用gpu(gtx1080) cudnn 5.1下編譯faster rcnn

GPU (CUDA 8.0,Cudnn5.1 ) Faster-rcnn

caffe都弄好的情況下~~~~(現在的版本faster-rcnn據說只支持cudnn 3版本的,所以在這之上要是想使用cudnn的都需要經過替換文件,下面有提到)

特別注意,你每一次編譯的時候都需要把之前編譯好的文件清除,否則編譯不成功,在 ~/py-faster-rcnn/caffe-fast-rcnn下執行 make clean 操作就是清除上一次編譯(沒有成功的編譯在你希望重新編譯的時候都需要make clean)

一:

Clone the Faster R-CNN repository

# Make sure to
clone with --recursive
git clone
--recursive https://github.com/rbgirshick/py-faster-rcnn.git
  • We'll call the directory that you cloned Faster R-CNN intoFRCN_ROOT

Ignore notes 1 and 2 if you followedstep 1 above.

Note 1:If you didn't clone Faster R-CNN with the --recursiveflag, then you'll need to manually clone the caffe-fast-rcnnsubmodule:

git submodule
update --init --recursive

Note 2:The caffe-fast-rcnn sub moduleneeds to be on the faster-rcnn branch(or equivalent detached state). This will happen automatically ifyou followed step 1 instructions.

上面就是官方文檔給出的正確clonefasterrcnn的方法和如果不按照這個給定方法執行所產生的後果:漏裝了caffe-fast-rcnn(這個文件在後面很重要,如果沒有它,下面的工作無法執行)

二:

下載demo模型數據

cd $FRCN_ROOT
$
./data/scripts/fetch_faster_rcnn_models.sh

This will populate the $FRCN_ROOT/datafolder with faster_rcnn_models. Seedata/README.md for details. These modelswere trained on VOC 2007 trainval.

py-faster-rcnn的路徑下找到執行後面到文件./data/scripts/fetch_faster_rcnn_models.sh,所下載的模型會放在py-faster-rcnn的路徑下的data文件夾下,名爲faster_rcnn_models.(其實也可以不用執行指令下載的,你可以在其他地方下載好了,放在data目錄下就好了~)

三:

修改文件:

1.  執行:cp Makefile.config.exampleMakefile.config (caffe-fast-rcnn目錄下)

$ cp Makefile.config.exampleMakefile.config(caffe-fast-rcnn目錄下)

2.  打開Makefile.config:文件找到相應的地方添加下面的黃色的內容,修改

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/

保存退出,注意新加的內容和原來的有空格隔開

否則會出現什麼hdf5.o文件找不到~

3.  更改Makefile.config文件:去掉use_cudnn前面的註釋 #


#Unrelatedly, it's also recommended that you use CUDNN

USE_CUDNN:= 1


4.  因爲這個版本所用的cudnn爲舊版本的,可能與新環境的cudnn不兼容

 所以你需要:

1)./py-faster-rcnn/caffe-fast-rcnn/include/caffe/util/cudnn.hpp換成最新版的caffe裏的cudnn的實現,即相應的cudnn.hpp.

)./py-faster-rcnn/caffe-fast-rcnn/include/caffe/layers中所有以cudnn開頭的文件都(建議到該目錄下了之後,使用文件搜索功能替換)用最新caffe源碼的以下文件替換掉fasterrcnn 的對應文件(一般在caffe目錄下的相同目錄下:~caffe/include/caffe/layersxx文件)

)./py-faster-rcnn/caffe-fast-rcnn/src/caffe/layers中所有以cudnn開頭的文件都(建議到該目錄下了之後,使用文件搜索功能替換)用最新caffe(就是賈陽青的那個框架裏面的文件)源碼的中對應文件替換掉(一般在caffe目錄下的相同目錄下:~caffe/src/caffe/layersxx文件)

注意是所有文件哦~所有以cudnn開頭的文件拉~

否則導致出現如下錯誤:

In file includedfrom ./include/caffe/util/device_alternate.hpp:40:0,

from ./include/caffe/common.hpp:19,

from ./include/caffe/blob.hpp:8,

from ./include/caffe/layer.hpp:8,

from src/caffe/layer_factory.cpp:8:

./include/caffe/util/cudnn.hpp:In function ‘voidcaffe::cudnn::createPoolingDesc(cudnnPoolingStruct**,caffe::PoolingParameter_PoolMethod, cudnnPoolingMode_t*, int, int,int, int, int, int)’:

./include/caffe/util/cudnn.hpp:127:41: error:too few arguments to function ‘cudnnStatus_t

5.Makefile.config文件中的WITH_PYTHON_LAYER:= 1前面的註釋#去掉~

WITH_PYTHON_LAYER:= 1 (Makefile.config文件中)

一定要注意把這個的註釋也去掉了,否則下面會出現這種類似的問題(也就是去掉“ # ”)

( 類似的問題:

F110302:52:40.782572 12953 layer_factory.hpp:81] Check failed:registry.count(type) == 1 (0 vs. 1) Unknown layer type: Python (knowntypes: AbsVal, Accuracy, ArgMax, BNLL, BatchNorm, BatchReindex, Bias,Concat, ContrastiveLoss, Convolution, Data, Deconvolution, Dropout,DummyData, ELU, Eltwise, Embed, EuclideanLoss, Exp, Filter, Flatten,HDF5Data, HDF5Output, HingeLoss, Im2col, ImageData, InfogainLoss,InnerProduct, LRN, Log, MVN, MemoryData, MultinomialLogisticLoss,PReLU, Pooling, Power, ROIPooling, ReLU, Reduction, Reshape, SPP,Scale, Sigmoid, SigmoidCrossEntropyLoss, Silence, Slice,SmoothL1Loss, Softmax, SoftmaxWithLoss, Split, TanH, Threshold, Tile,WindowData)

*** Check failurestack trace: ***

)

6.安裝easydict

$ sudo pip installl easydict (ubuntu根目錄下執行,其實哪裏執行都ok吧)

一般不建議這樣子安裝,因爲很多時候會出現問題,建議自己去下載壓縮包,解壓,cd到解壓後的文件目錄下,你就會看到setup.py文件,在該目錄下執行

$ sudo pythonsetup.py install 就可以安裝這個庫了(這是必須要的庫文件,否則編譯的時候會出現類似說沒有easydict庫文件的問題)

不建議使用$ python setup.pyinstall來安裝setup.py,因爲我遇到過下面這種問題

( 

siahooar@siahooar:~/pip-1.5.6$python setup.py install

running install

error:can't create or remove files in install directory


siahooar@siahooar:~/pip-1.5.6$sudo python setup.py install (換成sudoxxx 就好了)

running install

running bdist_egg

running egg_info

四。

編譯Cpython(Build the Cython modules)

$ cd $FRCN_ROOT/lib (py-faster-rcnn/lib目錄下)

$ make
五。
編譯caffe-fast-rcnn
(Build Caffe and pycaffe)
cd
$FRCN_ROOT/caffe-fast-rcnn (py-faster-rcnn/caffe-fast-rcnn目錄下)

然後在該目錄下執行:make–j4 && make pycaffe

$ make -j4 &&
make pycaffe
六:
運行程序自帶的一個例子驗證你的faster-rcnn
$ cd py-faster-rcnn
$ ./tools/demo.py
後面就不貼圖了 成功了都一樣
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章