Ubuntu 17.04 py-faster-rcnn only CPU
来源:互联网 发布:淘宝卖假货没人管吗 编辑:程序博客网 时间:2024/06/06 20:50
操作系统:ubuntu 17.04
python:Python 2.7.13
下载代码和数据
git clone –recursive https://github.com/rbgirshick/py-faster-rcnn.git
下载demo模型数据
cd py-faster-rcnn
./data/scripts/fetch_faster_rcnn_models.sh
如果这个过程由于网络原因中断下载,可以在下面链接中下载后,解压,复制到相应的 data目录下
链接:http://pan.baidu.com/s/1slkdcS1 密码:2ug2
安装Caffe需要的依赖包
将caffe-fast-rcnn/python目录下的requirements下的依赖都装一遍pip install XX(安装了anaconda的可以conda install XXX)
Cython>=0.19.2numpy>=1.7.1scipy>=0.13.2scikit-image>=0.9.3matplotlib>=1.3.1ipython>=3.0.0h5py>=2.2.0leveldb>=0.191networkx>=1.8.1nose>=1.3.0pandas>=0.12.0python-dateutil>=1.4,<2protobuf>=2.5.0python-gflags>=2.0pyyaml>=3.10Pillow>=2.3.0six>=1.1.0
修改setup.py
进入lib目录,修改setup.py,注释掉GPU相关代码,主要有三处,如下
安装Faster RCNN代码自带的caffe
进入caffe-fast-rcnn目录,
修改CMakeLists.txt文件,OFF改成ON,修改如下
caffe_option(CPU_ONLY "Build Caffe without CUDA support" ON) # TODO: rename to USE_CUDA
然后复制,命令: cp Makefile.config.example Makefile.config
修改Makefile.config为
## Refer to http://caffe.berkeleyvision.org/installation.html# Contributions simplifying and improving our build system are welcome!# cuDNN acceleration switch (uncomment to build with cuDNN).# USE_CUDNN := 1# CPU-only switch (uncomment to build without GPU support).CPU_ONLY := 1# uncomment to disable IO dependencies and corresponding data layers# USE_OPENCV := 0# USE_LEVELDB := 0# USE_LMDB := 0# uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary)# You should not set this flag if you will be reading LMDBs with any# possibility of simultaneous read and write# ALLOW_LMDB_NOLOCK := 1# Uncomment if you're using OpenCV 3# OPENCV_VERSION := 3# To customize your choice of compiler, uncomment and set the following.# N.B. the default for Linux is g++ and the default for OSX is clang++# CUSTOM_CXX := g++# CUDA directory contains bin/ and lib/ directories that we need.CUDA_DIR := /usr/local/cuda# On Ubuntu 14.04, if cuda tools are installed via# "sudo apt-get install nvidia-cuda-toolkit" then use this instead:# CUDA_DIR := /usr# CUDA architecture setting: going with all of them.# For CUDA < 6.0, comment the *_50 lines for compatibility.CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \ -gencode arch=compute_20,code=sm_21 \ -gencode arch=compute_30,code=sm_30 \ -gencode arch=compute_35,code=sm_35 \ -gencode arch=compute_50,code=sm_50 \ -gencode arch=compute_50,code=compute_50# BLAS choice:# atlas for ATLAS (default)# mkl for MKL# open for OpenBlasBLAS := atlas# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.# Leave commented to accept the defaults for your choice of BLAS# (which should work)!BLAS_INCLUDE := /usr/include/atlasBLAS_LIB := /usr/lib/atlas-base# Homebrew puts openblas in a directory that is not on the standard search path# BLAS_INCLUDE := $(shell brew --prefix openblas)/include# BLAS_LIB := $(shell brew --prefix openblas)/lib# This is required only if you will compile the matlab interface.# MATLAB directory should contain the mex binary in /bin.# MATLAB_DIR := /usr/local# MATLAB_DIR := /Applications/MATLAB_R2012b.app# NOTE: this is required only if you will compile the python interface.# We need to be able to find Python.h and numpy/arrayobject.h.PYTHON_INCLUDE := /usr/include/python2.7 \ /usr/lib/python2.7/dist-packages/numpy/core/include# Anaconda Python distribution is quite popular. Include path:# Verify anaconda location, sometimes it's in root.# ANACONDA_HOME := $(HOME)/anaconda# PYTHON_INCLUDE := $(ANACONDA_HOME)/include \ # $(ANACONDA_HOME)/include/python2.7 \ # $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include \# Uncomment to use Python 3 (default is Python 2)# PYTHON_LIBRARIES := boost_python3 python3.5m# PYTHON_INCLUDE := /usr/include/python3.5m \# /usr/lib/python3.5/dist-packages/numpy/core/include# We need to be able to find libpythonX.X.so or .dylib.PYTHON_LIB := /usr/lib# PYTHON_LIB := $(ANACONDA_HOME)/lib# Homebrew installs numpy in a non standard path (keg only)# PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include# PYTHON_LIB += $(shell brew --prefix numpy)/lib# Uncomment to support layers written in Python (will link against Python libs)WITH_PYTHON_LAYER := 1# Whatever else you find you need goes here.INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include \ /usr/include/hdf5/serial/LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib# If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies# INCLUDE_DIRS += $(shell brew --prefix)/include# LIBRARY_DIRS += $(shell brew --prefix)/lib# Uncomment to use `pkg-config` to specify OpenCV library paths.# (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)# USE_PKG_CONFIG := 1BUILD_DIR := buildDISTRIBUTE_DIR := distribute# Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171# DEBUG := 1# The ID of the GPU that 'make runtest' will use to run unit tests.TEST_GPUID := 0# enable pretty build (comment to see full commands)Q ?= @
修改Makefile第181行,一般用vim打开,如果没有显示行号,可以用:set number
命令显示行号。这块一定要记住自己改了什么,一般不同的版本可能会不一样,可以自行查找版本对应的。
编译caffe和pycaffe
~/py-faster-rcnn/caffe-fast-rcnn$ make ~/py-faster-rcnn/caffe-fast-rcnn$ make pycaffe ~/py-faster-rcnn/lib$ make
如果成功的话,如下图:
中间可能会遇到XX包不存在之类的问题,缺啥补啥。
注:遇到问题修改后,最好先make clean后再make
修改py-faster-rcnn相关配置
修改 ~/py-faster-rcnn/lib/fast_rcnn/config.py的内容,改为False:
修改 ~/py-faster-rcnn/tools/test_net.py和 ~/py-faster-rcnn/tools/train_net.py的caffe.set_mode_gpu()修改为caffe.set_mode_cpu()
将~/py-faster-rcnn/lib/setup.py中,含有’nms.gpu_nms’的部分去掉,去掉后的内容如下:
还需要将:~/py-faster-rcnn/lib/fast_rcnn/nms_wrapper.py中的from nms.gpu_nms import gpu_nms注释掉:
运行demo.py
在环境一切就绪的情况下,在~/py-faster-rcnn/tools目录下运行, python demo.py --cpu
:
出现错误:Check failed:*ptr host allocation of size 17280000 failed
输入sudo apt-get install ocl-icd-opencl-dev
但是由于我本身内存不够,程序仍然被杀死
所以我的电脑对于VGG16这个网络不能执行,只能运行小一点的网络,“ZF”,输入:python demo.py –cpu –net zf
结果成功:
其中一些结果:
更多教程,论文解析,资源,请关注微信公众号:paper大讲堂(paperclassroom)
- Ubuntu 17.04 py-faster-rcnn only CPU
- ubuntu 上运行 py-faster-rcnn
- py-faster-rcnn配置过程(ubuntu)
- py-faster-rcnn配置CPU下运行demo.py
- Caffe——py-faster-rcnn使用和搭建[Ubuntu——CPU]
- py-faster-rcnn+cpu配置并训练自己的数据
- ubuntu14.04安装CPU版caffe以及py-faster-rcnn
- ubuntu14.04、CPU的py-faster-rcnn安装步骤
- ubuntu16.04配置py-faster-rcnn(CPU版)
- Mac下跑仅CPU模式下的py-faster-rcnn
- Faster RCNN roidb.py
- Faster RCNN train_faster_rcnn_alt_opt.py
- Faster RCNN layer.py
- Faster RCNN train.py
- Faster RCNN generate.py
- Faster RCNN blob.py
- Faster RCNN minibatch.py
- Faster RCNN pascal_voc.py
- gulp工具使用
- eclipse 配置黑色主题
- PHP学习(1)-基础总结
- C# DateTime日期格式化
- 算法面试之回溯法
- Ubuntu 17.04 py-faster-rcnn only CPU
- 全文检索
- leetcode_649. Dota2 Senate ? 待解决
- 【Deep Learning】R-CNN
- 从零开始在iPhone上运行视频流实时预测模型应用,只需10步
- 学车经验总结(科目二)
- linux下nohup的使用
- 常见的内存泄漏
- 终端修改数据库密码 MAC