1. 程式人生 > >faster-rcnn在ubuntu16.04環境下的超級詳細的配置

faster-rcnn在ubuntu16.04環境下的超級詳細的配置

$ sudo cp Makefile.config.example Makefile.config # 備份配置檔案
$ sudo gedit 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 := 1
# 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 OpenBlas
BLAS := mkl
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
# BLAS_INCLUDE := /path/to/your/blas
# BLAS_LIB := /path/to/your/blas

# 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)/anaconda2
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 /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial

# 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 := 1

BUILD_DIR := build
DISTRIBUTE_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中,由於faster rcnn用的是老版本的caffe,不支援cudnnv5,所以需要修改。

Makefile: 找到第397行,NVCCFLAGS += -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)修改為NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS) (添加了-D_FORCE_INLINES引數 更新用到的caffe:原版py-faster-rcnn依賴的caffe比較老,不支援cudnnv5,那就更新下對應的原始碼。 用最新caffe原始碼的以下檔案替換掉faster rcnn 的對應檔案 include/caffe/layers/cudnn_relu_layer.hpp, src/caffe/layers/cudnn_relu_layer.cpp, src/caffe/layers/cudnn_relu_layer.cu
include/caffe/layers/cudnn_sigmoid_layer.hpp, src/caffe/layers/cudnn_sigmoid_layer.cpp, src/caffe/layers/cudnn_sigmoid_layer.cu include/caffe/layers/cudnn_tanh_layer.hpp, src/caffe/layers/cudnn_tanh_layer.cpp, src/caffe/layers/cudnn_tanh_layer.cu 用caffe原始碼中的這個檔案替換掉faster rcnn 對應檔案 include/caffe/util/cudnn.hpp 將 faster rcnn 中的 src/caffe/layers/cudnn_conv_layer.cu 檔案中的所有 cudnnConvolutionBackwardData_v3 函式名替換為 cudnnConvolutionBackwardData cudnnConvolutionBackwardFilter_v3函式名替換為 cudnnConvolutionBackwardFilter

然後執行 make -j8

最後執行 make pycaffe



7、編譯成功之後

在全部編譯成功之後,還不能完全代表環境配置正確。先跑一個demo,訓練或者識別,先試一下,環境是否正常。這編譯成功只是代表著程式碼環境沒有了問題,如果需要訓練或者識別,要下載VOC資料集和與訓練模型。

1️⃣下載VOC2007資料集

解壓,然後,將該資料集放在py-faster-rcnn\data下,用你的資料集替換VOC2007資料集。(替換Annotations,ImageSets和JPEGImages)

(用你的Annotations,ImagesSets和JPEGImages替換py-faster-rcnn\data\VOCdevkit2007\VOC2007中對應資料夾)

2️⃣下載ImageNet資料集下預訓練得到的模型引數(用來初始化)

解壓,然後將該檔案放在py-faster-rcnn\data下

配置好環境之後,訓練自己製作的資料集 1、將自己製作的資料集(pic和xml)放到faster-rcnn的根目錄下的data中。其中Annotation用來存放xml檔案,JPEGImages用來存放圖片,ImagesSets用來存放參與訓練的檔名。在所有參與訓練的檔案中,有一部分的比例是Trainval,其餘是test。然後Trainval中又有一部分是train,另外一部分是val。訓練需要將檔案隨機的分配給trianval和test,所以需要一個指令碼將參與訓練的檔案隨機按照比例分配。在這裡是一個matlab的程式2、安置好待訓練的資料集之後,需要根據自己訓練的分類的類別修改相應的配置。 對於不同的訓練方式,需要更改的地方不同。 ①alt_opt訓練方式 a,修改 py-faster-rcnn/models/pascal_voc/ZF/faster_rcnn_alt_opt資料夾下的四個階段的訓練檔案。 stage1_fast_rcnn_train.pt stage1_rpn_train.pt stage2_fast_rcnn_train.pt stage2_rpn_train.pt faster_rcnn_test.pt 主要修改裡面的num_output數值。 b,修改py-faster-rcnn/lib/datasets資料夾下面的pascal_voc.py檔案 主要修改self._classes = ('__background__','自己的標籤1','自己的標籤2','自己的標籤3') ②end2end訓練方式 a,修改py-faster-rcnn/models/pascal_voc/VGG_CNN_M_1024/faster_rcnn_end2end資料夾裡面的 train.prototxt solver.prototxt test.prototxt 三個檔案 b,修改py-faster-rcnn/lib/datasets資料夾下面的pascal_voc.py檔案 主要修改self._classes = ('__background__','自己的標籤1','自己的標籤2','自己的標籤3') 3、修改迭代次數 ①、alt_opt訓練方式 修改py-faster-rcnn\tools資料夾下的train_faster_rcnn_alt_opt.py檔案。 max_iters = [80000, 40000, 80000, 40000]分別代表四個階段 ②、end2end訓練方式 直接修改experiments/scripts/faster_rcnn_end2end.sh裡面的iters變數的值。 4、開始訓練 ./experiments/scripts/faster_rcnn_alt_opt.sh 0 ZF pascal_voc   ./experiments/scripts/faster_rcnn_end2end.sh 0 VGG_CNN_M_1024 pascal_voc   類似於這樣的命令,在faster-rcnn的根目錄下執行指令碼檔案,後面的0代表的是GPU的編號,ZF是選用的網路,也可以是VGG_CNN_M_1024也可以是VGG16。pascal_voc是指資料集的格式。兩種訓練方式都一樣。 注意:在開始訓練之前一定要記得刪除output和兩個cache。 5、測試自己的測試圖片 a、將訓練好的模型拷貝到相應的位置。將訓練得到的caffemodel(在output資料夾下面的不同訓練方式的資料夾西面)拷貝至py-faster-rcnn\data\faster_rcnn_models。 b、將要測試的圖片拷貝到data下面的demo資料夾下面。 c、執行./toos/demo.py --net vgg_cnn 遇到的問題

“fatal error: hdf5.h: 沒有那個檔案或目錄”解決方法

Step 1

Makefile.config檔案的第85行,新增/usr/include/hdf5/serial/ 到 INCLUDE_DIRS,也就是把下面第一行程式碼改為第二行程式碼。

INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
  • INCLUDE_DIRS:= $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/

Step 2

Makefile檔案的第173行,把 hdf5_hl 和hdf5修改為hdf5_serial_hl 和 hdf5_serial,也就是把下面第一行程式碼改為第二行程式碼。

LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial

相關推薦

faster-rcnn在ubuntu16.04環境超級詳細配置

$ sudo cp Makefile.config.example Makefile.config # 備份配置檔案 $ sudo gedit Makefile.config # 修改編譯檔案 `````````````````````````````````````````````````````

Ubuntu 18.04環境搭建SSR(shadowsocksR)詳細流程

Ubuntu 18.04環境下搭建SSR(shadowsocksR)詳細流程 配置SSR客戶端 注意 Solution: 更方便的處理方法,寫個指令碼: 配置SSR客戶端 Shadowsocks與Shadow

Ubuntu 16.04環境Kdevelop安裝和配置

哈哈哈 Kdevelop是一個很棒的IDE, 不僅是因為他免費也是因為它在Ubuntu的原始檔中提供了, 所以呢,只需要敲幾行程式碼就可以輕鬆下載啦。 我在這裡再濃縮下,提煉下精華: 安裝cmake:sudo apt-get install cmake

Ubuntu16.04環境Pythonxlearn機器學習庫的配置

一、xlearn的簡介參見:https://www.zhihu.com/question/37256015/answer/268151326,http://www.sohu.com/a/206728248_206784        在機器學習裡,除了深度學習和樹模型 (GB

ubuntu 14.04伺服器環境apache2.4配置SSL

最近因為開發微信小程式,需要在服務端搭建https,在網上找了幾篇配置SSL的部落格,感覺都不是特別滿意,感覺這一篇寫的還挺好的。1.查詢apache的SSL模組ubuntu下,apache的預設模組目錄是/usr/lib/apache2/modules/$ cd /usr/

Ubuntu16.04環境MySQL5.7安裝&配置以及遠端訪問

mysql> set character_set_client=utf8; mysql> set character_set_connection=utf8; mysql> set character_set_database=utf8; mysql> set charact

Ubuntu16.04環境PythonLightgbm機器學習庫的配置

一、Lightgbm簡介   xgboost的出現,讓調參俠們告別了傳統的機器學習演算法們:RF、GBM、SVM、LASSO等等,而微軟推出了一個新的boosting框架Lightgbm更是向前進一步,漸漸有取代的xgboost這一開源框架地位的趨勢。相比於xgboost,L

Ubuntu16.04環境Vim 配置 for HTML,CSS,JAVASCRIPT(1)

vimr vimrc ref res runt sta all mpat () 參考了三篇文章: VIM配置---面向前端 使用Vundle管理配置Vim基本插件 CSS 語法高亮 1、安裝Vundle git clone https://github.com/Vund

windows環境wampserver的配置教程

module 單獨 ext 寫作 還需 sta write 打開 服務器 對於初做PHP網站的朋友來說,第一步肯定是希望在自己電腦是搭建PHP環境,省去空間和上傳的麻煩!但搭建環境也不是件容易的事情,特別是對於新手同學來說!因此在這裏跟大家介紹我作為一名新手在使用的方便好用

Mac環境SVN的配置和使用

nbsp 環境 配置 創建 bsp cnblogs 執行 use 使用   簡單記錄一下在Mac環境下,SVN的配置步驟和使用相關。(Mac自帶了svn的服務器和客戶端功能,簡單配置一下即可使用)   一、SVN的配置方法   1. 創建一個倉庫目錄,比如在/Users/你

Spring Cloud 入門教程(四): 分布式環境自動發現配置服務

.html article png discover ice conf label tail 註釋 前一章, 我們的Hello world應用服務,通過配置服務器Config Server獲取到了我們配置的hello信息“hello world”. 但自己的配置文件中必須配

linux環境jdk部署配置

etc $path 是否 ssp java jdk1 配置系統 exp 執行文件 1、java官網下載相關的jdk包 2、配置系統環境變量,編輯/etc/profile文件,在文件的末尾添加一下信息: export JAVA_HOME=/usr/jdk1.8.0_101ex

OpenStack之安裝4網卡ubuntu-14.04及網絡詳細配置

安裝ubuntu14.04 網絡配置 virtualbox openstack 四個網卡:網絡1:物理機與虛擬機連接,為host-only類型,主要用來管理網絡,它的dhcp off。網絡2:Open vSwitch占用網絡,也是Host-only類型網絡3:OpenStack中有一些存儲組件

大數據測試之hadoop單機環境搭建(超級詳細版)

com jvm 末尾 內容 取數 搭建 cluster replicat specific 友情提示:本文超級長,請備好瓜子 Hadoop的運行模式 單機模式是Hadoop的默認模式,在該模式下無需任何守護進程,所有程序都在單個JVM上運行,該模式主要用於開發和調試map

VMware + ubuntu16.04 Linux 安裝、配置Gogs

自己 不知道 advance bsp 空間 home apt-get gogs systemctl 本文在Win7+VMware的ubuntu 16.04中測試。運行如下命令: sudo apt-get install git sudo adduser git # 為Go

Linux環境Redis安裝配置步驟[轉]

http redis-cli ont == LV 成功 fcm space 執行 在LInux下安裝Redis的步驟如下: 1、首先下載一個Redis安裝包,官網下載地址為:https://redis.io/ 2、在Linux下解壓redis: tar -zxvf re

SSM 環境的 AOP 配置與簡單應用

一、需要匯入的 jar 包 <!-- Spring AOP 日誌管理需要匯入的包 --> <dependency> <groupId>org.aspectj</groupId> <

在Windows環境安裝及配置gcc編譯器

我們都知道,gcc是GNU作業系統的編譯套件,那麼在Windows系統下可以使用gcc嗎?答案是可以的。 介紹MinGW 首先我們先介紹下MinGW,MinGM是指只用自由軟體來生成純粹的Win32可執行檔案的編譯環境,它是Minimalist GNU on Windows的略稱,見名知意,

Ubuntu16.04環境通過Cmake管理Opencv專案

Ubuntu16.04環境下通過Cmake管理Opencv專案 1、新建qt cmake工程 New Project -> Non-Qt Project -> Plain C++ Application 2、CMakeLists.txt檔案內

ubuntu 16.04 環境:Wukonchatbot——語音喚醒:hot

語音喚醒 and hotword 參考snowboy 支援:linux、樹莓派、moc 和windows 製作過程: - 1.snowboy 喚醒模型製作: - 2.環境安裝:(ubuntu) - 3.測試你的喚醒詞 snowboy 官網 1.snow