CAFFE安裝 CentOS無GPU

來源:互聯網
上載者:User

標籤:

 前記

由於是在一台用了很久的機器上安裝caffe,過程比較複雜,網上說再乾淨的機器上裝比較簡單。如果能有乾淨的機器,就不用再過這麼多坑了,希望大家好運!介紹這裡就不說了,直接進入正題:

Caffe 首頁  http://caffe.berkeleyvision.org/

github首頁 https://github.com/BVLC/caffe

機器配置: 

[[email protected] build]# lsb_release -aLSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarchDistributor ID:    RedHatEnterpriseServerDescription:    Red Hat Enterprise Linux Server release 6.3 (Santiago)Release:    6.3

gcc 版本 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)

Python 2.7.10 

 python已安裝numpy,沒有GPU

Prerequisites
  • CUDA is required for GPU mode.
    • library version 7.0 and the latest driver version are recommended, but 6.* is fine too
    • 5.5, and 5.0 are compatible but considered legacy
  • BLAS via ATLAS, MKL, or OpenBLAS.
  • Boost >= 1.55
  • OpenCV >= 2.4 including 3.0
  • protobufgloggflags
  • IO libraries hdf5leveldbsnappylmdb

Pycaffe and Matcaffe interfaces have their own natural needs.

  • For Python Caffe: Python 2.7 or Python 3.3+numpy (>= 1.7), boost-provided boost.python
  • For MATLAB Caffe: MATLAB with the mex compiler.

1.  安裝各種依賴包

yum install -y gcc gcc-c++ gtk+-devel libjpeg-devel libtiff-devel jasper-devel libpng-devel zlib-devel cmakeyum install git gtk2-devel pkgconfig numpy python python-pip python-devel gstreamer-plugins-base-devel libv4l ffmpeg-devel mplayer mencoder flvtool2yum install libdc1394 libdc1394-devel.x86_64yum install gtk*

2. python包安裝

下載Caffe源碼,按照./caffe/caffe-master/python/requirements.txt 安裝所需要的包,用pip安裝比較方便,不行就自己下載手動安裝,沒什麼問題。

3. 安裝protobufgloggflags

先從比較簡單的來:

 

4. 安裝CUDA

 從nvidia網站上下載最新的CUDA7.5,按自己的作業系統進行選擇,這裡選擇下載cuda_7.5.18_linux.run,直接運行:

./cuda_6.5.14_linux_64.run

運行後會出現選擇安裝的項目,選擇不安裝驅動,否則會出錯(driver installation is unable to locate the kernel source),也就是第一個選項No

5. 安裝OpenBLAS

 ATLAS, MKL, or OpenBLAS都可以安裝,以前用過OpenBLAS,這次就還裝他吧

下載OpenBLAS源碼,安裝也很簡單,make && make install即可,更多請參考 OpenBLAS編譯和安裝簡介

6. 安裝OpenCV

 OpenCV裝起來比較麻煩,中間遇到了很多問題,參考安裝文檔,也可以參考網上很多人給的 自動安裝配置指令碼,由於我安裝時出了很多問題,所以基本是自己手動裝的。

首先將自己的CMake升級到最新版本,yum預設裝的預設不行,只能手動升級了,否則在CMake階段就會出現各種警告什麼的。

下載OpenCV-3.0.0

unzip opencv-3.0.0.zipcd opencv-3.0.0mkdir buildcd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..

##如果不出問題
make -j 32
sudo make install
sudo sh -c ‘echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf‘
sudo ldconfig

下面說說我在make的時候碰到的問題:

Q1:已經安裝了ffmpeg,出現錯誤AVCodecID未聲明

cap_ffmpeg_impl.hpp:1556:83:錯誤:使用枚舉‘AVCodecID’前沒有給出聲明

A1: 解決的方法是,添加make參數 -D WITH_FFMPEG=OFF,參考

 

Q2:出現parallel_for_pthreads undefined reference 錯誤,貌似是只有在CentOs中才會出現的

A2: 需要更改modules/core/src/parallel.cpp檔案,參考1,參考2,我這裡只按照參考2給了parallel.cpp檔案

 

Q3: 出現undefined reference to `jpeg_default_qtables‘

../../../lib/libopencv_imgcodecs.so.3.0.0: undefined reference to `jpeg_default_qtables‘

A3:安裝,jpegsrc.v9a.tar.gz, 參考1, 參考2, 參考3

tar -xzvf jpegsrc.v9.tar.gzcd jpeg-9./configuremake libdir=/usr/lib64make libdir=/usr/lib64 install

 

Q4:編譯已完成,但是還是有問題:

[100%] Linking CXX shared library ../../lib/cv2.so/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32 against `.rodata.str1.8‘ can not be used when making a shared object; recompile with -fPIC/usr/local/lib/libpython2.7.a: could not read symbols: Bad valuecollect2: ld 返回 1make[2]: *** [lib/cv2.so] 錯誤 1make[1]: *** [modules/python2/CMakeFiles/opencv_python2.dir/all] 錯誤 2make: *** [all] 錯誤 2

A4:重新編譯安裝python,configure時添加--enable-shared,參考

./configure --enable-sharedmakemake install

 重新安裝完以後可能會出現,執行python時error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory,解決方案是:

 vi /etc/ld.so.conf  #如果是非root許可權帳號登入,使用 sudo vi /etc/ld.so.conf  #添加上python2.7的lib庫地址,如我的/usr/local/Python2.7/lib,儲存檔案/sbin/ldconfig

 

7. 安裝Caffe

如果以上安裝沒有什麼問題,這一不應該不會出錯

unzip caffe-master.zipcd caffe-mastercp Makefile.config.example Makefile.configvim Makefile.config 
# 按照實際情況修改配置 CPU_ONLY := 1 BLAS := open

make all

8. 運行MINIST例子

參考

cd $CAFFE_ROOT./data/mnist/get_mnist.sh./examples/mnist/create_mnist.sh

 

 

 

CAFFE安裝 CentOS無GPU

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.