caffe版faster-RCNN环境搭建

- 基本按照官网上的readme

1.电脑上已经有可运行caffe所需的环境

2.下载faster-rcnn python版本源码

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

3. 进入/py-faster-rcnn/lib 进行编译,build the Cython modules

    cd py-faster-rcnn/lib
    make  

问题:

python setup.py build_ext --inplace
running build_ext
cythoning utils/bbox.pyx to utils/bbox.c

Error compiling Cython file:
------------------------------------------------------------
...
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Sergey Karayev
# --------------------------------------------------------

cimport cython
       ^
------------------------------------------------------------

utils/bbox.pyx:8:8: Compiler crash in AnalyseDeclarationsTransform

File ‘ModuleNode.py‘, line 122, in analyse_declarations: ModuleNode(bbox.pyx:1:0,
    full_module_name = ‘utils.cython_bbox‘)
File ‘Nodes.py‘, line 408, in analyse_declarations: StatListNode(bbox.pyx:8:0)
File ‘Nodes.py‘, line 408, in analyse_declarations: StatListNode(bbox.pyx:8:8)
File ‘Nodes.py‘, line 7396, in analyse_declarations: CImportStatNode(bbox.pyx:8:8,
    module_name = u‘cython‘)

  File "/home/dsp/anaconda2/lib/python2.7/site-packages/Cython/Utils.py", line 148, in search_include_directories
    path = os.path.join(dir, dotted_filename)
  File "/home/dsp/anaconda2/lib/python2.7/posixpath.py", line 73, in join
    path += ‘/‘ + b
UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte 0xe6 in position 10: ordinal not in range(128)
building ‘utils.cython_bbox‘ extension
gcc -pthread -B /home/dsp/anaconda2/compiler_compat -Wl,--sysroot=/ -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/dsp/anaconda2/lib/python2.7/site-packages/numpy/core/include -I/home/dsp/anaconda2/include/python2.7 -c utils/bbox.c -o build/temp.linux-x86_64-2.7/utils/bbox.o -Wno-cpp -Wno-unused-function
utils/bbox.c:1:2: error: #error Do not use this file, it is the result of a failed Cython compilation.
 #error Do not use this file, it is the result of a failed Cython compilation.
  ^
error: command ‘gcc‘ failed with exit status 1
Makefile:2: recipe for target ‘all‘ failed
make: *** [all] Error 1
  • 先各种百度,安装cython等;结果发现时路径的坑
  • 神坑:路径;py-faster-rcnn存放位置路径中不能有中文,否则报错UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte 0xe6 in position
  • 最后放到  /home/uername/ 下直接makec成功

4.编译/py-faster-rcnn/caffe-fast-rcnn

cd py-faster-rcnn/caffe-fast-rcnn
make -j32 && make pycaffe
  • Makefile.config文件直接用的本机配置caffe的文件
  • 问题:
In file included from ./include/caffe/util/device_alternate.hpp:40:0,
                 from ./include/caffe/common.hpp:19,
                 from ./include/caffe/blob.hpp:8,
                 from src/caffe/blob.cpp:4:
./include/caffe/util/cudnn.hpp:8:34: fatal error: caffe/proto/caffe.pb.h: 没有那个文件或目录

- 按照:解决方法: 用protoc从caffe/src/caffe/proto/caffe.proto生成caffe.pb.h和caffe.pb.cc ,http://blog.csdn.net/xmzwlw/article/details/48270225没有作用;后面还有一串错误

In file included from ./include/caffe/util/device_alternate.hpp:40:0,
                 from ./include/caffe/common.hpp:19,
                 from ./include/caffe/blob.hpp:8,
                 from ./include/caffe/layers/loss_layer.hpp:6,
                 from src/caffe/layers/loss_layer.cpp:3:
./include/caffe/util/cudnn.hpp: In function ‘const char* cudnnGetErrorString(cudnnStatus_t)’:
./include/caffe/util/cudnn.hpp:21:10: warning: enumeration value ‘CUDNN_STATUS_RUNTIME_PREREQUISITE_MISSING’ not handled in switch [-Wswitch]
   switch (status) {
          ^
./include/caffe/util/cudnn.hpp: In function ‘void caffe::cudnn::setConvolutionDesc(cudnnConvolutionStruct**, cudnnTensorDescriptor_t, cudnnFilterDescriptor_t, int, int, int, int)’:
./include/caffe/util/cudnn.hpp:108:70: error: too few arguments to function ‘cudnnStatus_t cudnnSetConvolution2dDescriptor(cudnnConvolutionDescriptor_t, int, int, int, int, int, int, cudnnConvolutionMode_t, cudnnDataType_t)’
       pad_h, pad_w, stride_h, stride_w, 1, 1, CUDNN_CROSS_CORRELATION));
                                                                      ^
./include/caffe/util/cudnn.hpp:15:28: note: in definition of macro ‘CUDNN_CHECK’
     cudnnStatus_t status = condition;                             ^
In file included from ./include/caffe/util/cudnn.hpp:5:0,
                 from ./include/caffe/util/device_alternate.hpp:40,
                 from ./include/caffe/common.hpp:19,
                 from ./include/caffe/blob.hpp:8,
                 from ./include/caffe/layers/loss_layer.hpp:6,
                 from src/caffe/layers/loss_layer.cpp:3:
/usr/local/cuda/include/cudnn.h:500:27: note: declared here
 cudnnStatus_t CUDNNWINAPI cudnnSetConvolution2dDescriptor( cudnnConvolutionDescriptor_t convDesc,
                           ^
In file included from ./include/caffe/util/device_alternate.hpp:40:0,
                 from ./include/caffe/common.hpp:19,
                 from ./include/caffe/blob.hpp:8,
                 from ./include/caffe/layers/loss_layer.hpp:6,
                 from src/caffe/layers/loss_layer.cpp:3:
./include/caffe/util/cudnn.hpp: In function ‘void caffe::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 cudnnSetPooling2dDescriptor(cudnnPoolingDescriptor_t, cudnnPoolingMode_t, cudnnNanPropagation_t, int, int, int, int, int, int)’
         pad_h, pad_w, stride_h, stride_w));
                                         ^
./include/caffe/util/cudnn.hpp:15:28: note: in definition of macro ‘CUDNN_CHECK’
     cudnnStatus_t status = condition;                             ^
In file included from ./include/caffe/util/cudnn.hpp:5:0,
                 from ./include/caffe/util/device_alternate.hpp:40,
                 from ./include/caffe/common.hpp:19,
                 from ./include/caffe/blob.hpp:8,
                 from ./include/caffe/layers/loss_layer.hpp:6,
                 from src/caffe/layers/loss_layer.cpp:3:

  // Caffe utility functions
  bp::def("init_log", &InitLog);
  bp::def("init_log", &InitLogLevel);
  bp::def("init_log", &InitLogLevelPipe);
  bp::def("log", &Log);
  bp::def("has_nccl", &HasNCCL);
  bp::def("set_mode_cpu", &set_mode_cpu);
  bp::def("set_mode_gpu", &set_mode_gpu);
  bp::def("set_random_seed", &set_random_seed);
  bp::def("set_device", &Caffe::SetDevice);
<<<<<<< HEAD
  bp::def("set_random_seed", &Caffe::set_random_seed);
=======
  bp::def("solver_count", &Caffe::solver_count);
  bp::def("set_solver_count", &Caffe::set_solver_count);
  bp::def("solver_rank", &Caffe::solver_rank);
  bp::def("set_solver_rank", &Caffe::set_solver_rank);
  bp::def("set_multiprocess", &Caffe::set_multiprocess);
>>>>>>> caffe/master

- 最后编译成功;faster-rcnn 安装里面也提到了处理版本不兼容,进行文件替换的方法

AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0
CXX/LD -o .build_release/tools/convert_imageset.bin
CXX/LD -o .build_release/tools/train_net.bin
CXX/LD -o .build_release/tools/finetune_net.bin
CXX/LD -o .build_release/tools/compute_image_mean.bin
CXX/LD -o .build_release/tools/upgrade_net_proto_text.bin
CXX/LD -o .build_release/tools/test_net.bin
CXX/LD -o .build_release/tools/upgrade_net_proto_binary.bin
CXX/LD -o .build_release/tools/upgrade_solver_proto_text.bin
CXX/LD -o .build_release/tools/net_speed_benchmark.bin
CXX/LD -o .build_release/tools/device_query.bin
CXX/LD -o .build_release/tools/extract_features.bin
CXX/LD -o .build_release/examples/cifar10/convert_cifar_data.bin
CXX/LD -o .build_release/examples/mnist/convert_mnist_data.bin
CXX/LD -o .build_release/examples/cpp_classification/classification.bin
CXX/LD -o .build_release/tools/caffe.bin
CXX/LD -o .build_release/examples/siamese/convert_mnist_siamese_data.bin
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
touch python/caffe/proto/__init__.py
PROTOC (python) src/caffe/proto/caffe.proto

5、下载Faster R-CNN的预训练模型

cd py-faster-rcnn
./data/scripts/fetch_faster_rcnn_models.sh

6、运行demo.py

cd py-faster-rcnn
./tools/demo.py
  • Reference

CNN目标检测(一):Faster RCNN详解

faster-rcnn 安装

Faster R-CNN 的Caffe实现

时间: 2024-10-12 01:27:43

caffe版faster-RCNN环境搭建的相关文章

Caffe研究实践一------环境搭建

和TensorFlow对应的是Theano,Torch: Caffe专精于图像处理,Caffe方便,更快入门上手: 在通用的DL task上,Caffe不如Theano. 开发环境搭建: 一.没有GPU [email protected]-virtual-machine:~$ lspci | grep -i nvidia [email protected]-virtual-machine:~$ 二.ubuntu版本 [email protected]:~$ uname -m && cat

免安装版MySQL的环境搭建(补2016-09-19)

1.在官网下载所需要的MySQL版本,安装版非常简单的就不再说了 官网下载链接 2.设置环境变量 2.1 将下载好的压缩包解压,记住bin文件夹所在的路径: 2.2 在"我的电脑->属性->高级系统设置->环境变量"中,将bin文件夹所在的路径配置到path中,不同环境变量之间用分号(;)分隔 3.配置MySQL 3.1 找到MySQL的解压路径,找到my-default.ini文件,修改文件中的basedir和datadir. basedir: MySQL的解压路径

iOS版 React Native 环境搭建

今天没事,搞了搞React Native,也都是才开始弄,并没有感受过它的强大,嘿嘿.今天算是demo可以跑了吧.特此记录一下搭建过程,留着日后使用. 特此声明,才过程,不保证百分百成功,因为本人在搭建的时候参考了好多东西相关文章,还请各位看官自请斟酌,啦啦啦啦我都是这么"负责任". 极客学院的官方文档中文版 -- 特此奉上-- 传送门  主要的学习参考对象, 此内容中可以看到英文文档 此外,安装步骤参考的是,这篇文章,这里记录是为了自己观看方便,和参考文章有点出入 搭建步骤如下: H

算法 第4版 eclipse下环境搭建

主页上有相关的环境配置 http://algs4.cs.princeton.edu/windows/ 下载algs4.exe 然后安装就好了,但是这样会进行很多无用的步骤. 平时既然使用的是eclipse,那么就直接在eclipse下配置就好啦. 工作其实很简单,就是将stdlib.jar和algs4.jar两个包添加进你的工程就好啦. 在工程的Build Path下选择 Add External Archives 然后找到stdlib.jar和algs4.jar就可以了. 另外书本上有很多程序

纯C++版500VIP源码下载的Faster R-CNN(通过caffe自定义RPN层实现)

这里500VIP源码下载 dsluntan.com 介绍的是通过添加自定义层(RPN层)代替python层,实现c++版的Faster R-CNN,因为去掉python了,所以部署时不会因为牵扯到python库等其它的莫名其妙的错误,使用起来就跟单纯的caffe一样,更简单方便. 核心代码,借鉴的是这篇博客,这里的话,我们不扣具体的代码细节(比如rpn层是怎么产出候选框啊,非极大值抑制是具体怎么实现的等等),有兴趣的可以自己查下资料,所以主要是走一个步骤,从而完成c++版Faster R-CNN

Widows下Faster R-CNN的MATALB配置(GPU)

目录 1. 准备工作 2. VS2013编译Caffe 3. Faster R-CNN的MATLAB源码测试 说在前面,这篇是关于Windows下Faster R-CNN的MATLAB配置,GPU版本:CPU版本见:Widows下Faster R-CNN的MATALB配置(CPU): 相比较来说,CPU版本相对容易一些,因为涉及到GPU的计算,还需要配置CUDA以及CuDNN: 下面将分成三个部分进行介绍: 准备工作:下载caffe.faster rcnn源码.安装cuda.cudnn: VS2

Ubuntu14.04+caffe+cuda7.5 环境搭建以及MNIST数据集的训练与测试

Ubuntu14.04+caffe+cuda 环境搭建以及MNIST数据集的训练与测试 一.ubuntu14.04的安装: ubuntu的安装是一件十分简单的事情,这里给出一个参考教程: http://jingyan.baidu.com/article/76a7e409bea83efc3b6e1507.html 二.cuda的安装: 1.首先下载nvidia cuda的仓库安装包(我的是ubuntu 14.04 64位,所以下载的是ubuntu14.04的安装包,如果你是32位的可以参看具体的地

lua环境搭建 + 常见错误解决 windows + linux双版

lua在linux和windows系统下的安装/配置方法 linux系统: 1)去Lua的官网(http://www.lua.org/ftp/)下载最新发布包,比如lua-5.2.3.tar.gz 2)使用命令tar -xzvf  lua-5.2.3.tar.gz  解压 3)使用命令cd lua-5.2.3 进入lua目录 4)使用命令make linux 此时如出现问题,解决方法如下: 问题:error: <readline/history.h>: No such file or dire

faster-rcnn(testing): ubuntu14.04+caffe+cuda7.5+cudnn5.1.3+opencv3.0+matlabR2014a环境搭建记录

python版本的faster-rcnn见我的另一篇博客: py-faster-rcnn(running the demo): ubuntu14.04+caffe+cuda7.5+cudnn5.1.3+python2.7环境搭建记录 1. 首先需要配置编译caffe的环境,并降级gcc为4.7.见: ubuntu14.04下安装cudnn5.1.3,opencv3.0,编译caffe及matlab和python接口过程记录(不好意思,这也是我自己写的) 2. clone 源码: git clon