How to Install Caffe 1.0 With Anaconda Python3 on Centos7

Caffe is a deep learning framework made with expression, speed, and modularity in mind. It is developed by Berkeley AI Research (BAIR) and by community contributors.

The official website is http://caffe.berkeleyvision.org/ .

It is easy to install it with python 2 and Ubuntu.But it is hard to install it with python 3 and centOs.

Here are some records when I install it with Anaconda python3 on centos7.

Platform

Prior to installing, have a glance through this blog and take note of the details for your platform.

$cat /etc/redhat-release
  
  CentOS Linux release 7.*.* (Core)
  
  $python --version
  
  Python 3.4.3 :: Anaconda 2.3.0 (64-bit)
  
  $pip --version
  
  pip 7.0.3 from /home/work/anaconda3/lib/python3.4/site-packages (python 3.4)

Dependencies

$sudo yum install gflags-devel glog-devel lmdb-devel openblas-devel leveldb-devel snappy-devel opencv-devel hdf5-devel

Python and boost Dependencies

Fist of all,download the dependencies.

$git clone --depth 1 https://github.com/BVLC/caffe.git
  
  $wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz/download
  
  $wget 'https://github.com//protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz'
  
  $wget 'https://github.com//protobuf/releases/download/v3.3.0/protobuf-python-3.3.0.tar.gz'

Install the dependencies:

1.python libs:

$cd caffe/python
  
  $for req in $(cat requirements.txt) pydot; do /usr/bin/pip install $req -i https://pypi.mirrors.ustc.edu.cn/simple; done

If you are not in China,remove the -i url parameter.

2.pb libs:

$cd ../..;tar zxvf boost_1_59_0.tar.gz;tar zxvf protobuf-cpp-3.3.0.tar.gz;tar zxvf protobuf-python-3.3.0.tar.gz
  
  $cd protobuf-3.3.0/
  
  $./configure
  
  $make && make install
  
  $cd python/
  
  $python setup.py build
  
  $python setup.py install
  
  $sudo ln -s /usr/local/lib/libprotobuf.so.13.0.0 /usr/lib64/libprotobuf.so.13

3.boost libs:

$cd boost_1_59_0/
  
  $./bootstrap.sh 
  
  $./b2 cxxflags="-I /home/work/anaconda3/include/python3.4m/"
  
  $sudo ./b2 install --prefix=/usr cxxflags="-I /home/work/anaconda3/include/python3.4m/"

Install Caffe

The last step:

$cd caffe
  
  $git checkout -b 1.0
  
  $vim Makefile.config
  
  change the config like this:
  
  BLAS := open
  
  BLAS_INCLUDE := /usr/include/openblas
  
  PYTHON_INCLUDE := /home/work/anaconda3/include \
                         /home/work/anaconda3/include/python3.4m \
                         /home/work/anaconda3/lib/python3.4/site-packages/numpy/core/include
  
  PYTHON_LIBRARIES := boost_python3 python3.4m
  
  $make
  
  $make pycaffe
  
  $export PYTHONPATH=$PYTHONPATH:/home/work/soft/src/caffe/python

TEST

$cd caffe
  $make test && make runtest

Good luck!


原创文章如转载,请注明:转载自五四陈科学院[http://www.54chen.com]

捐款订阅54chen
捐赠说明