安装cuda

cuda8安装参见网上教程

安装cuDNN

py-faster-rcnn/caffe-fast-rcnn目前不支持cuDNN5。
如果使用cuDNN5,在编译caffe-fast-rcnn时会报错:

error: argument of type “int” is incompatible with parameter of type “cudnnNanPropagation_t”
解决编译错误的方法参见我的另一篇博客:
《使用cuDNN5编译py-faster-rcnn错误:cudnn.hpp(126): error: argument of type “int” is incompatible …》

如果使用cuDNN4就不会有编译错误。
cuDNN安装方式(cuDNN4为例)

tar zxvf cudnn-7.0-linux-x64-v4.0-prod.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp -d cuda/lib64/libcudnn* /usr/local/cuda/lib64 

cuDNN4 OR 5?

那么应该安装cuDNN4还是cuDNN5呢?
这取决于你的NVIDIA显卡与cuDNN之间是否有兼容性问题。
如果你的电脑上用cuDNN4能正常执行demo,那自然好,
如果不能,就换cuDNN5试试,原因参见我的另一篇博客
《cuDNN兼容性问题造成的caffe/mnist,py-faster-rcnn/demo运行结果错误》

下载faster r-cnn代码

$git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git

下载模型数据

模型数据有点大,要花点时间

$./data/scripts/fetch_faster_rcnn_models.sh

编译caffe

这里的caffe是Faster R-CNN自带的caffe,在caffe-fast-rcnn文件夹下

$cd caffe-fast-rcnn
#如果没有cmake,要安装cmake
#$sudo apt-get install cmake
# 执行cmake生成Makefile
#编译CPU版本
#cmake -DCPU_ONLY=ON -DBLAS=Open .
#编译GPU版本
$cmake -DBLAS=Open -DCUDA_NVCC_FLAGS=--Wno-deprecated-gpu-targets .
$make -j 8

关于编译caffe的细节参见我的另一篇博客 《Ubuntu16:cmake生成Makefile编译caffe过程(OpenBLAS/CPU+GPU)塈解决nvcc warning:The ‘compute_20’, ‘sm_20’》

安装pycaffe的依赖库

caffe-fast-rcnn/python/requirement.txt文件列出了pycaffe的所有依赖库,要把requirements下的依赖都装一遍

guyadong@10km-ubuntu:~/tmp/py-faster-rcnn/caffe-fast-rcnn/python$ cat requirements.txt
Cython>=0.19.2
numpy>=1.7.1
scipy>=0.13.2
scikit-image>=0.9.3
matplotlib>=1.3.1
ipython>=3.0.0
h5py>=2.2.0
leveldb>=0.191
networkx>=1.8.1
nose>=1.3.0
pandas>=0.12.0
python-dateutil>=1.4,<2
protobuf>=2.5.0
python-gflags>=2.0
pyyaml>=3.10
Pillow>=2.3.0

pycaffe的依赖库是用Python的包管理工具pip来安装的,如果还没安装pip,则要先安装python-pip

$ sudo apt-get install python-pip
$ sudo apt-get install python-opencv
$ sudp apt-get install python-tk
$ sudo apt-get install python-dateutil
$ cd caffe-fast-rcnn/python
$ for req in $(cat requirements.txt); do sudo pip install $req; done
$ sudo pip install easydict

编译faster-rcnn

编译好caffe-fast-rcnn后,在py-faster-rcnn/lib中执行make命令:

$ make
running build
running build_ext
skipping ‘utils/bbox.c’ Cython extension (up-to-date)
building ‘utils.cython_bbox’ extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/utils
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c utils/bbox.c -o build/temp.linux-x86_64-2.7/utils/bbox.o -Wno-cpp -Wno-unused-function
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/utils
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/utils/bbox.o -o build/lib.linux-x86_64-2.7/utils/cython_bbox.so
skipping ‘nms/cpu_nms.c’ Cython extension (up-to-date)
building ‘nms.cpu_nms’ extension
creating build/temp.linux-x86_64-2.7/nms
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c nms/cpu_nms.c -o build/temp.linux-x86_64-2.7/nms/cpu_nms.o -Wno-cpp -Wno-unused-function
creating build/lib.linux-x86_64-2.7/nms
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/nms/cpu_nms.o -o build/lib.linux-x86_64-2.7/nms/cpu_nms.so
skipping ‘nms/gpu_nms.cpp’ Cython extension (up-to-date)
building ‘nms.gpu_nms’ extension
/usr/local/cuda-8.0/bin/nvcc -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/local/cuda-8.0/include -I/usr/include/python2.7 -c nms/nms_kernel.cu -o build/temp.linux-x86_64-2.7/nms/nms_kernel.o -arch=sm_35 –ptxas-options=-v -c –compiler-options ‘-fPIC’
ptxas info : 0 bytes gmem
ptxas info : Compiling entry function ‘_Z10nms_kernelifPKfPy’ for ‘sm_35’
ptxas info : Function properties for _Z10nms_kernelifPKfPy
0 bytes stack frame, 0 bytes spill stores, 0 bytes spill loads
ptxas info : Used 25 registers, 1280 bytes smem, 344 bytes cmem[0], 8 bytes cmem2
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/local/cuda-8.0/include -I/usr/include/python2.7 -c nms/gpu_nms.cpp -o build/temp.linux-x86_64-2.7/nms/gpu_nms.o -Wno-unused-function
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1777:0,
from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:18,
from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayobject.h:4,
from nms/gpu_nms.cpp:449:
/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning “Using deprecated NumPy API, disable it by ” “#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION” [-Wcpp]
#warning “Using deprecated NumPy API, disable it by ” \
^
c++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/nms/nms_kernel.o build/temp.linux-x86_64-2.7/nms/gpu_nms.o -L/usr/local/cuda-8.0/lib64 -Wl,-R/usr/local/cuda-8.0/lib64 -lcudart -o build/lib.linux-x86_64-2.7/nms/gpu_nms.so
skipping ‘pycocotools/_mask.c’ Cython extension (up-to-date)
building ‘pycocotools._mask’ extension
creating build/temp.linux-x86_64-2.7/pycocotools
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/lib/python2.7/dist-packages/numpy/core/include -Ipycocotools -I/usr/include/python2.7 -c pycocotools/maskApi.c -o build/temp.linux-x86_64-2.7/pycocotools/maskApi.o -Wno-cpp -Wno-unused-function -std=c99
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/lib/python2.7/dist-packages/numpy/core/include -Ipycocotools -I/usr/include/python2.7 -c pycocotools/_mask.c -o build/temp.linux-x86_64-2.7/pycocotools/_mask.o -Wno-cpp -Wno-unused-function -std=c99
creating build/lib.linux-x86_64-2.7/pycocotools
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/pycocotools/maskApi.o build/temp.linux-x86_64-2.7/pycocotools/_mask.o -o build/lib.linux-x86_64-2.7/pycocotools/_mask.so

运行demo

$python tools/demo.py 

….
I0314 16:11:46.644143 22175 net.cpp:270] This network produces output bbox_pred
I0314 16:11:46.644161 22175 net.cpp:270] This network produces output cls_prob
I0314 16:11:46.644192 22175 net.cpp:283] Network initialization done.
[libprotobuf WARNING google/protobuf/io/coded_stream.cc:537] Reading dangerously large protocol message. >If the message turns out to be larger than 2147483647 bytes, parsing will be halted for security reasons. To >increase the limit (or to disable these warnings), see CodedInputStream::SetTotalBytesLimit() in >google/protobuf/io/coded_stream.h.
[libprotobuf WARNING google/protobuf/io/coded_stream.cc:78] The total number of bytes read was 548317115
I0314 16:11:46.803853 22175 net.cpp:816] Ignoring source layer data
I0314 16:11:46.873862 22175 net.cpp:816] Ignoring source layer drop6
I0314 16:11:46.883658 22175 net.cpp:816] Ignoring source layer drop7
I0314 16:11:46.883672 22175 net.cpp:816] Ignoring source layer fc7_drop7_0_split
I0314 16:11:46.883926 22175 net.cpp:816] Ignoring source layer loss_cls
I0314 16:11:46.883936 22175 net.cpp:816] Ignoring source layer loss_bbox
I0314 16:11:46.885593 22175 net.cpp:816] Ignoring source layer silence_rpn_cls_score
I0314 16:11:46.885612 22175 net.cpp:816] Ignoring source layer silence_rpn_bbox_pred
Loaded network /home/guyadong/tmp/py-faster-rcnn/data/faster_rcnn_models/VGG16_faster_rcnn_final.caffemodel
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo for data/demo/000456.jpg
Detection took 2.097s for 300 object proposals
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo for data/demo/000542.jpg
Detection took 1.695s for 161 object proposals
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo for data/demo/001150.jpg
Detection took 1.908s for 194 object proposals
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo for data/demo/001763.jpg
Detection took 1.785s for 196 object proposals
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo for data/demo/004545.jpg
Detection took 1.881s for 300 object proposals

如果在CPU上运行,要复杂一些,需要手工修改一些脚本,参见《Faster R-CNN CPU环境搭建》.

参考资料

《Faster R-CNN CPU环境搭建》
《Faster R-CNN安装笔记,只用CPU 》

cuda8+cuDNN Faster R-CNN安装塈运行demo相关推荐

  1. Faster R CNN

    Faster R CNN 3 FASTER R-CNN 我们的Faster R CNN 由两个模块组成,第一个模块是 proposes regions 的全卷积网络,第二个是使用 proposed r ...

  2. 不安装cudnn可不可以_Ubuntu16.04+gtx1060+cuda8.0+cudnn8.0+tensorflow安装

    折腾了两天系统安装和配置,简单的记录一下. 1.Ubuntu16.04安装 1)先去官网找到对应的版本,我这里安装的是Ubuntu16.04 ltx版本,下载地址为:https://www.ubunt ...

  3. R与RStudio官网安装与运行过程中的注意事项

    (一)安装过程 安装版本:R 4.0.0.RStudio2022.02.0-443 安装包下载地址:R:http://cran.r-project.org/ RStudio:https://www.r ...

  4. 不安装cudnn可不可以_ubuntu16.04 安装NVIDIA和CUDA9.2 cudNN7.1

    1.安装NVIDIA驱动 (1)查询NVIDIA驱动 首先去官网(http://www.nvidia.com/Download/index.aspx?lang=en-us)查看适合自己显卡的驱动(下载 ...

  5. linux下驱动、cuda、cudnn、tensorflow的安装(转载)

    前言: 安装TensorFlow的GPU版本真的不是一件容易的事,好难,网上的各种安装教程倒是不少,但是基本没有一个能完全照着那种方法就能安装成功的,甚至有些连最基本的一些必需的步骤都没写到,那样子的 ...

  6. Faster R-CNN的安装及测试(Python版本和Matlab版本)

    rbg的Python版本 一.拉取源码 git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git 拉取完成后,在/h ...

  7. win7_64+tensorflow1.4+cuda8.0+cudnn6.0+GTX1050安装

    本来很久以前就在实验室的笔记本上安装好了win10_64+tensorflow1.4+cuda8.0+cudnn6.0+GT610.但是今天跑demo的时候,发现只能在cpu上跑.不知道是不是610显 ...

  8. ubuntu16.04+cuda8.0+cudnn5.1+caffe 安装(基于独立主机集成显卡GTX1080Ti)

    最近开始配置自己的深度学习主机,由于之前只在笔记本上和单显卡主机上安装过,所以可以说是zero经验,以至于很多问题不了解都当成了bug,故为了方便以后的自己以及大众,特在此写下post一篇.(由于可能 ...

  9. R语言-安装使用指南

    R语言 概述 R语言是用于统计分析,图形表示和报告的编程语言和软件环境. R语言由Ross Ihaka和Robert Gentleman在新西兰奥克兰大学创建,目前由R语言开发核心团队开发. R语言的 ...

最新文章

  1. es创建索引数量多了好还是少了好_Elasticsearch性能优化总结
  2. Cocos2d-X开发中国象棋《三》開始场景的实现
  3. 十年.十大经济金融事件
  4. Message启动菜单个性化制作工具V1.0.3.1最终版
  5. Adobe MAX 2011第一天主题演讲实录
  6. win10右键没有新建笔记本
  7. 【连载】线性代数笔记——第二章矩阵
  8. 用ln命令链接文件 --- 一根绳子上的蚂蚱?
  9. 中国传媒大学计算机课程表,中国传媒大学播本课表.pdf
  10. Lambda与Stream流
  11. 职业学校的老师教计算机,职业院校计算机教学方式方法分析
  12. 公钥和私钥的完全解释(包括对称算法和非对称算法、RSA解释)
  13. 还在为写调查问卷发愁的你赶快来看看这个自动填写问卷(问卷星版)
  14. bootstrap 后端模板
  15. Java IO NIO NIO2
  16. 1000个苹果要分到10个箱子中去 两种分析方式
  17. Windows 7 开机自动拨号 常用的五种方
  18. VMware上安装centOS,能ping通本地,但是ping不了外网怎么办
  19. mercurymw305r虚拟服务器,Mercury MW305R v3.0 路由器改造 LEDE(OpenWRT)
  20. iOS通过http post上传图片, 文件等

热门文章

  1. 灰色GM(1,1)模型及其在电力负荷预测中的应用附Matlab代码
  2. 【android】android真机测试方法
  3. mac 教程 安装cocoapod(100%成功)试过无数次
  4. 微信公众号开发 如何发布图文并茂的文章?
  5. 【操作系统】30天自制操作系统--(9)叠加处理
  6. 异常处理·MSSQL·在将nvarchar值‘XXX‘转换成数据类型int时失败
  7. 2019年广东工业大学腾讯杯新生程序设计竞赛(同步赛)E-缺席的神官
  8. Python 办公小助手:读取 PDF 中表格并重命名
  9. 吴明计算机二级二级试题,全国计算机二级ffice-word-历年真题.docx
  10. matlab fourier变换反变换