您的位置:首页 > 其它

Ubuntu16.04+cuda8.0+cudnnV5.1配置faster-rcnn的方法

2017-08-02 15:00 567 查看
Python版本可以按以下步骤DIY训练Faster-RCNN

1.下载Faster-RCNN源代码并安装

  通过git工具直接下载,在Linux 命令行输入:

  $ git clone —recursive https://github.com/rbgirshick/py-faster-rcnn.git
        PS : —recursive 是用来caffe-fast-rcnn (也就是caffe branch)的,这个必须要加上,否则此文件夹为空

2. 编译Cython模块

  在 /py-faster-rcnn/lib directory 目录下执行命令:

        $  cd py-faster-rcnn/lib
  $ make


3.拷贝Makefile.config,并修改Makefile.config

        $
cd py-faster-rcnn/caffe-fast-rcnn

        $ cp Makefile.config.example Makefile.config

        更改Makefile.config文件:

           1)#USE_CUDNN := 1行,去掉#变为  USE_CUDNN := 1 ,如果你的计算机的计算能力能够支持cudnn 。

         2)Add the following lines in
Makefile.config


不然编译的时候会报错,如果不加这两行,会出hdf5.h找不到的错误,还有其他的错误,总之,加上就对了。

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/

注意:新加的行前面需空一个空格。
  3)
4000
#WITH_PYTHON_LAYER
:= 1
,去掉#变为
WITH_PYTHON_LAYER
:= 1[/code],因为faster R-CNN是要python接口的,所以这一项要有,不能注释。

否则会在运行demo.py的时候遇到这样错误:



4.编译Caffe和Pycaffe

         $
make -j4 && make pycaffe


因为这个版本所用的cudnn为旧版本的,可能与新环境的cudnn不兼容,导致出现如下错误:




make: *** [.build_release/src/caffe/util/db.o] Error 1  

make: *** Waiting for unfinished jobs.... 

      03.  make: *** [.build_release/src/caffe/layers/cudnn_relu_layer.o] 错误 1
解决办法:


  
1)将py-faster-rcnn/caffe-fast-rcnn/include/caffe/util/cudnn.hpp
文件替换为[code]caffe/include/caffe/util/cudnn.hpp

,即相应的cudnn.hpp.[/code]


  2)将
py-faster-rcnn/caffe-fast-rcnn/include/caffe/layers
文件夹中所有以cudnn的文件替换[code]为caffe/include/caffe/layers
文件夹中相应的
cudnn开头
文件。 

  3)将
py-faster-rcnn/caffe-fast-rcnn/src/caffe/layers
文件夹中所有以cudnn开头的文件替换为
caffe/src/caffe/layers
文件夹中相应的cudnn开头的文件,例如cudnn_lrn_layer.cu,cudnn_pooling_layer.cpp等。
[/code]

5.
下载已训练好的Faster R-CNN模型

  $
cd
py-faster-rcnn


注意这个脚本中提供的网址现在需要翻墙才能连接并下载,不过如果实在下载不了的话就自己训练吧。
6. 运行python的demo

     执行以下命令:

  $ cd
py-faster-rcnn



    ./tools/demo.py


  1)出现如下错误ImportError: No module named easydict


       


       缺少Python库easydict,所以安装 pip install easydict,执行以下命令

       $ sudo pip install easydict

       2)出现如下错误:ImportError: No module named cv2

      


  缺少Python库cv2,这个是openCV里面的。执行以下命令来装openCV python

  $ sudo apt-get install python-opencv

        3)出现如下错误:ImportError: No module named _tkinter, please install the python-tk package

  


        由于Python的版本没有包含tkinter的模块,执行以下命令安装tk的package。

  $ sudo apt-get install python-tk

        接下来运行基于Python的demo,大功告成。

  $ /home/bay/py-faster-rcnn/tools/demo.py

  


7.执行demo.py的效果图

  


 

  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: