小白安裝caffe、py-faster-rcnn艱難歷程

安裝anaconda:

  • 下載:https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/

      bash anaconda.....sh
    
      enteryes..
    
  • 測試 :anaconda是否配置好可以通過在終端輸入如下代碼的方式:

      conda list
    
  • 如果提示錯誤,則說明沒有配置好,需要進行下面的步驟:

     sudogedit ~/.bashrc
    
     打開文件後在末尾輸入 :export PATH="/home/***/anaconda2/bin:$PATH"
    
     此處anaconda2的路徑根據你自己的做相應的修改即可。
    
     輸入後打開一個新終端,輸入python
    

安裝caffeCPU版本:

安裝無顯卡驅動的cuda

1. makeall

  • 問題:各種未定義的引用

    解決

cd caffe
cp Makefile.config.example Makefile.config
mkdir build
cd build
cmake ..
./configure
 make all
  • 問題:nvccfatal : Unsupported gpu architecture ‘compute_60’

CMakeError at cuda_compile_generated_nesterov_solver.cu.o.cmake:206(message):

Errorgenerating

/home/kuang/caffe/build/src/caffe/CMakeFiles/cuda_compile.dir/solvers/./cuda_compile_generated_nesterov_solver.cu.o

make[2]:*[src/caffe/CMakeFiles/cuda_compile.dir/solvers/./cuda_compile_generated_nesterov_solver.cu.o]錯誤1

make[1]:* [src/caffe/CMakeFiles/caffe.dir/all]錯誤2

make:* [all]錯誤2

解決

make clean
rm-rf ./build/*
make all

準備好了.執行

      make pycaffe

      make all

      make test

      make runtest
  • 問題:import caffe失敗:ImportError:No module named caffe

    解決

in caffe root dir

make all

make pycaffe

make distribute
#make dir for custom python modules, install caffe
mkdir ~/python
mv  distribute/python/caffe ~/python 
#添加環境變量
sudo gedit  ~/.bashrc
將 export PYTHONPATH=/home/×××/caffe/python:$PYTHONPATH 添加到文件中。
source~/.bashrc 使更改生效。
#這樣,在其他地方打開python,也可以 import caffe了。
  • 問題:Impor tError:No module named google.protobuf.internal

    解決:是在其中安裝protobuf最新版本

sudo chmod 777 -R anaconda2
conda install protobuf
  • 問題:之後測試 faster 的demo:錯誤原因已放棄(核心已轉儲)

解決:在運行程序時賦予管理員權限,也就是添加sudo

 缺少模塊:
 sudo pip install easydict 
 sudo apt-get install python-opencv
  • 問題:找不到caffe:

make:*沒有規則可以創建目標“pycaffe”。停止

faster下caffe編譯不成功:make-j8 && make pycaffe
出錯:errorThis file was generated by a newer version of protoc which is.build_release/src/caffe/proto/caffe.pb.h:13:2:error: #error incompatible with your Protocol Buffer headers. Pleaseupdate errorincompatible with your Protocol Buffer headers. Please update
.build_release/src/caffe/proto/caffe.pb.h:14:2:error: #error your headers.erroryour headers.
Infile included from ./include/caffe/blob.hpp:9:0,
from./include/caffe/layers/input_layer.hpp:6,
fromsrc/caffe/layers/input_layer.cpp:3:
.build_release/src/caffe/proto/caffe.pb.h:23:35:fatal error: google/protobuf/arena.h:沒有那個文件或目錄

include

sudo pip install --upgrade protobuf

安裝protobuf:http://blog.csdn.net/yl204/article/details/50478279

查看boost版本:

dpkg -S /usr/include/boost/version.hpp 

安裝opencv3: http://blog.csdn.net/forest_world/article/details/51372703

  • 問題:sudo make時出現問題:nvccfatal : Unsupported gpu architecture’compute_11’

解決:原因是CUDA7.5不支持較爲古老的顯卡版本,因此1.1,2.0,2.1,之類的顯卡選項是多餘的。
需要更改CmakeGUI對工程的配置,去掉對compute_11的支持

sudo cmake-D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -DCUDA_GENERATION=Kepler ./
 sudo cmake-D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -DCUDA_GENERATION=Kepler ./

然後再次sudo make:

  • 問題:astorage class is not allowed in an explicit specialization

    解決:/opencv-3.0.0-alpha\modules\cudalegacy\src\cuda\NCVPixelOperations.hpp

    第51行到68行119到131出現錯誤的行的staticinline修改成inline就可以了

然後到測試是否成功安裝:

http://www.tuicool.com/articles/nYJrYra

  • 問題:

OpenCV

Error: Unspecified error (The function is not implemented. Rebuildthe library with Windows, GTK+ 2.x or Carbon support. If you are onUbuntu or Debian, install libgtk2.0-dev and pkg-config, then re-runcmake or configure script) in cvNamedWindow, file/home/aborn/software/OpenCV-2.4.1/modules/highgui/src/window.cpp,line 598
terminate called after throwing an instance of’cv::Exception’
what(): /home/aborn/software/OpenCV-2.4.1/modules/highgui/src/window.cpp:598:error: (-2) The function is not implemented. Rebuild the library withWindows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian,install libgtk2.0-dev and pkg-config, then re-run cmake or configurescript in function cvNamedWindow

簡單的解釋就是你的GTK+2.x要先於OpenCV安裝,所以它給的解決方法是Youshould remove the current installation of opencv from your system;rebuild your opencv lib after installinggtk dev lib in the correct path; and reinstall the compiled opencvlib.

解決

在ubuntu下刪除OpenCV的步驟如下:

1)進入opencv的源代碼文件夾下的release(這是你在安裝opencv時候自己命名的,cmake時候所在的目錄)

2)依次執行下面的代碼

make uninstall

cd ..

sudo rm -r release

sudo rm -r /usr/local/include/opencv2 /usr/local/include/opencv
/usr/include/opencv /usr/include/opencv2 /usr/local/share/opencv
/usr/local/share/OpenCV /usr/share/opencv /usr/share/OpenCV
/usr/local/bin/opencv* /usr/local/lib/libopencv

正確的:::::

一定要先裝!!!!

安裝gtk:http://blog.csdn.net/qq_33259138/article/details/52129732

再裝http://blog.csdn.net/xukai871105/article/details/40988101

中間 刪掉static

/opencv-3.0.0-alpha\modules\cudalegacy\src\cuda\NCVPixelOperations.hpp (第51行到68行119到131)

opencv-3.0.0-alpha/modules/cudastereo/src/cuda/stereocsbp.cu(62,66,74)

make

sudo make install

下面配置library,打開/etc/ld.so.conf.d/opencv.conf,在末尾加入/usr/local/lib (有可能是個空文件,沒關係)

然後 sudoldconfig

然後編輯/etc/bash.bashrc

加入

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfigexportPKG_CONFIG_PATH

至此,opencv安裝配置完畢

下面開始測試

  • 問題:在rcnn的caffe裏make不成功:

.build_release/lib/libcaffe.so:對‘cv::imread(cv::Stringconst&, int)’未定義的引用

解決http://blog.csdn.net/xiaxiazls/article/details/52039473

  • 問題:.build_release/lib/libcaffe.so:對‘cv::imread(cv::Stringconst&, int)’未定義的引用

解決:執行要加cpu demo.py–cpu

繼續在pyfaste的caffe master 下
sudo make pycaffe:

LD
-o .build_release/lib/libcaffe.so.1.0.0-rc3

/usr/bin/ld:
找不到 -l
-llmdb

/usr/bin/ld:
找不到 -l
-lopencv_core

collect2:
error: ld returned 1 exit status

make:
* [.build_release/lib/libcaffe.so.1.0.0-rc3] 錯誤 1

.build_release/lib/libcaffe.so:對‘cv::imread(cv::Stringconst&, int)’未定義的引用

lableimg安裝:

由於Ubuntu系統自帶python,這款軟件在Ubuntu環境下的安裝是最方便的。軟件要求python版本在2.6以上,同時需要PyQt和lxml的支持。

sudo apt-get install pyqt4-dev-tools #安裝PyQt4

sudo pip install lxml #安裝lxml,如果報錯,可以試試下面語句

sudo apt-get install python-lxml

git clone https://github.com/tzutalin/labelImg.git

cd labelImg

make all

./labelImg.py

使用方法

修改默認的XML文件保存位置,使用快捷鍵“Ctrl+R”,改爲自定義位置,這裏的路徑一定不能包含中文,否則無法保存。

源碼文件夾中使用notepad++打開data/predefined_classes.txt,修改默認類別,比如改成person、car、motorcycle三個類別。

“OpenDir”打開圖片文件夾,選擇第一張圖片開始進行標註,使用“CreateRectBox”或者“Ctrl+N”開始畫框,單擊結束畫框,再雙擊選擇類別。完成一張圖片後點擊“Save”保存,此時XML文件已經保存到本地了。點擊“NextImage”轉到下一張圖片。

標註過程中可隨時返回進行修改,後保存的文件會覆蓋之前的。

完成標註後打開XML文件,發現確實和PASCALVOC所用格式一樣。

×

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章