使用gpu(gtx1080) cudnn 5.1下编译faster rcnn
GPU (CUDA 8.0,Cudnn5.1 ) Faster-rcnn
在caffe都弄好的情況下~~~~(現(xiàn)在的版本faster-rcnn據(jù)說只支持cudnn 3版本的,所以在這之上要是想使用cudnn的都需要經(jīng)過替換文件,下面有提到)
特別注意,你每一次編譯的時候都需要把之前編譯好的文件清除,否則編譯不成功,在 ~/py-faster-rcnn/caffe-fast-rcnn下執(zhí)行 make clean 操作就是清除上一次編譯(沒有成功的編譯在你希望重新編譯的時候都需要make clean)
一:
Clone the Faster R-CNN repository
# Make sure to clone with --recursivegit 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 thecaffe-fast-rcnnsubmodule:
git submodule update --init --recursiveNote 2:Thecaffe-fast-rcnn sub moduleneeds to be on the faster-rcnn branch(or equivalent detached state). This will happen automaticallyifyou followed step 1 instructions.
上面就是官方文檔給出的正確clonefasterrcnn的方法和如果不按照這個給定方法執(zhí)行所產(chǎn)生的后果:漏裝了caffe-fast-rcnn(這個文件在后面很重要,如果沒有它,下面的工作無法執(zhí)行)
二:
下載demo模型數(shù)據(jù)
cd $FRCN_ROOT$ ./data/scripts/fetch_faster_rcnn_models.shThis will populate the $FRCN_ROOT/datafolder withfaster_rcnn_models. Seedata/README.md for details. These modelswere trained on VOC 2007 trainval.
到py-faster-rcnn的路徑下找到執(zhí)行后面到文件./data/scripts/fetch_faster_rcnn_models.sh,所下載的模型會放在py-faster-rcnn的路徑下的data文件夾下,名為faster_rcnn_models.(其實也可以不用執(zhí)行指令下載的,你可以在其他地方下載好了,放在data目錄下就好了~)
三:
修改文件:
1. 執(zhí)行:cp Makefile.config.exampleMakefile.config (在caffe-fast-rcnn目錄下)
$ cp Makefile.config.exampleMakefile.config(在caffe-fast-rcnn目錄下)
2. 打開Makefile.config:文件找到相應(yīng)的地方添加下面的黃色的內(nèi)容,修改
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/
保存退出,注意新加的內(nèi)容和原來的有空格隔開
(
否則會出現(xiàn)什么hdf5.o文件找不到~
)
3. 更改Makefile.config文件:去掉use_cudnn前面的注釋 #
#Unrelatedly, it's also recommended that you use CUDNN
USE_CUDNN:= 1
4. 因為這個版本所用的cudnn為舊版本的,可能與新環(huán)境的cudnn不兼容
所以你需要:
1).將/py-faster-rcnn/caffe-fast-rcnn/include/caffe/util/cudnn.hpp換成最新版的caffe里的cudnn的實現(xiàn),即相應(yīng)的cudnn.hpp.
2).把/py-faster-rcnn/caffe-fast-rcnn/include/caffe/layers中所有以cudnn開頭的文件都(建議到該目錄下了之后,使用文件搜索功能替換)用最新caffe源碼的以下文件替換掉fasterrcnn的對應(yīng)文件(一般在caffe目錄下的相同目錄下:~caffe/include/caffe/layers/xx文件)
3).把/py-faster-rcnn/caffe-fast-rcnn/src/caffe/layers中所有以cudnn開頭的文件都(建議到該目錄下了之后,使用文件搜索功能替換)用最新caffe(就是賈陽青的那個框架里面的文件)源碼的中對應(yīng)文件替換掉(一般在caffe目錄下的相同目錄下:~caffe/src/caffe/layers/xx文件)
注意是所有文件哦~所有以cudnn開頭的文件拉~
否則導(dǎo)致出現(xiàn)如下錯誤:
(
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文件中)
一定要注意把這個的注釋也去掉了,否則下面會出現(xiàn)這種類似的問題(也就是去掉“# ”)
( 類似的問題: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根目錄下執(zhí)行,其實哪里執(zhí)行都ok吧)
一般不建議這樣子安裝,因為很多時候會出現(xiàn)問題,建議自己去下載壓縮包,解壓,cd到解壓后的文件目錄下,你就會看到setup.py文件,在該目錄下執(zhí)行
$ sudo pythonsetup.py install 就可以安裝這個庫了(這是必須要的庫文件,否則編譯的時候會出現(xiàn)類似說沒有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目錄下)然后在該目錄下執(zhí)行:make–j4 && make pycaffe
$ make -j4 && make pycaffe六:運(yùn)行程序自帶的一個例子驗證你的faster-rcnn$ cd py-faster-rcnn$ ./tools/demo.py后面就不貼圖了 成功了都一樣 與50位技術(shù)專家面對面20年技術(shù)見證,附贈技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的使用gpu(gtx1080) cudnn 5.1下编译faster rcnn的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python Anaconda2安装Op
- 下一篇: 深度学习框架caffe及py-faste