LoginSignup
6
6

More than 5 years have passed since last update.

CentOS7.2にCaffeをインストールして物体認識のサンプルを動かしてみる(20161003版)

Last updated at Posted at 2016-09-29

改版履歴

  • 10/03改版

    • 物体認識のサンプルが動作するまでの手順を追加
    • pip installで発生するパッケージが無いエラーを解消するため、以下を追加インストール

      wget lapack-devel blas-devel numpy-f2py freetype-devel libpng-devel libjpeg-turbo-devel
      
    • ビルド後のDockerイメージサイズを更新

    • Dockerfileの動作確認を実施

手順

  • Caffeの物体認識を試してみたかったので、ネットの記事を参考に環境構築を行ったメモ。

  • ライブラリのインストール(10/03修正)

    yum install -y epel-release
    yum install -y make cmake gcc gcc-c++ doxygen git python-devel python-pip numpy numpy-f2py unzip wget
    yum install -y protobuf-devel leveldb-devel snappy-devel opencv-devel boost-devel hdf5-devel gflags-devel glog-devel lmdb-devel atlas atlas-devel blas-devel openblas* lapack-devel freetype-devel libpng-devel libjpeg-turbo-devel
    
  • Caffeのインストール

    curl -OL https://github.com/BVLC/caffe/archive/master.zip
    unzip master.zip -d /opt
    mv /opt/caffe-master /opt/caffe
    cd /opt/caffe
    cp Makefile.config.example Makefile.config
    make all -e CPU_ONLY=1 -e BLAS=open
    make test -e CPU_ONLY=1 -e BLAS=open
    make runtest -e CPU_ONLY=1 -e BLAS=open
    
  • 物体認識のサンプル動作環境の設定

    cd /opt/caffe/data
    curl -OL http://www.vision.caltech.edu/Image_Datasets/Caltech101/101_ObjectCategories.tar.gz
    tar xf 101_ObjectCategories.tar.gz
    cd /opt/caffe/data/ilsvrc12
    ./get_ilsvrc_aux.sh
    cd /opt/caffe/models/bvlc_reference_caffenet/
    curl -OL http://dl.caffe.berkeleyvision.org/bvlc_reference_caffenet.caffemodel
    cd /opt/caffe/python/
    cat requirements.txt  | xargs -n1 pip install
    
  • 残りは以下を参照
    http://habatafuture.hatenablog.jp/entry/2015/09/19/001335
     

  • Dockerfile

    上記までの作業を行ったDockerfileを以下に登録。ビルドすると2.4GB程度になる。(10/03更新)
    https://github.com/r-hirakawa/docker
     

  • 補足

    • CentOS7でatlasを使うとmakeでエラーが出るため、makeのオプションに「-e BLAS=open」を指定し、openblasを利用
    • CPU版を利用するためmakeのオプションに「-e CPU_ONLY=1」を指定
    • 「pip install -r requirements.txt」は動かなかったので「cat requirements.txt | xargs -n1 pip install」に変更
6
6
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6