بلاگی در مورد دیجیتال،بینایی و یادگیری ماشین

اکانت های من:
www.github.com/salehjg
www.iranled.com/forum

طبقه بندی موضوعی

Installing Caffe with Aanaconda on CentOS7

يكشنبه, ۷ خرداد ۱۳۹۶، ۱۱:۰۶ ب.ظ

Prerequisites

NVidia Driver, Cuda Toolkit 7.5, cuDNN v5 or v5.1, Anaconda2-4.0.0 64bit or Anaconda2-4.2.0 64bit and OpenCV 3.1 (using conda installation) should be installed and configed following previous documents.

Install General Dependencies

# yum install protobuf-devel leveldb-devel snappy-devel opencv-devel boost-devel hdf5-devel
# yum install gflags-devel glog-devel lmdb-devel
# yum install openblas-devel

Download Caffe

Go to this page https://github.com/BVLC/caffe. Download the latest version.

Tested Version: 2c34393fc5aec9899d92c64be41598a3184d3347 (20160928) . This version is a refined version based on release candidate 3. Link: https://github.com/BVLC/caffe/archive/2c34393fc5aec9899d92c64be41598a3184d3347.zip

Download the file to /opt/ml-items, unzip it.

# wget https://github.com/BVLC/caffe/archive/2c34393fc5aec9899d92c64be41598a3184d3347.zip
# unzip 2c34393fc5aec9899d92c64be41598a3184d3347.zip
# mv caffe-2c34393fc5aec9899d92c64be41598a3184d3347 caffe-2c34393 

Config Makefile

# cd caffe-2c34393
# cp Makefile.config.example Makefile.config
# vi Makefile.config

If you do not want to change it one by one, a modified version of mine can be used. The steps for changing it are provided.

^^^^^^ Items for Change

User cuDNN

uncomment

USE_CUDNN := 1 

Use OpenCV version 3

uncomment

OPENCV_VERSION := 3

Use OpenBLAS

change

BLAS := atlas

to

BLAS := open

uncomment

BLAS\_INCLUDE

and change it to

BLAS_INCLUDE := /usr/include/openblas

uncomment

BLAS_LIB

and change it to B

LAS_LIB := /usr/lib64

Replace Default Path with Anaconda Path

comment

PYTHON_INCLUDE := /usr/include/python2.7/usr/lib/python2.7/dist-packages/numpy/core/include

uncomment

ANACONDA_HOME := $(HOME)/anaconda
PYTHON_INCLUDE

change it into

ANACONDA_HOME := /opt/anaconda2

comment

PYTHON_LIB := /usr/lib

uncomment

PYTHON_LIB := $(ANACONDA_HOME)/lib

uncomment

WITH_PYTHON_LAYER := 1

Add 64 bit Library Path

add

/usr/lib64

to the end of LIBRARY_DIRS

^^^^^^ End Items for Change

Compilation

Link OpenCV Libs

Since we install OpenCV using Anaconda, the path of OpenCV libraries are a little different with the normal installation. Link operations should be used.

# cd /usr/lib64
# ln -s /opt/anaconda2/lib/libhdf5.so.10 libhdf5.so.10
# ln -s /opt/anaconda2/lib/libhdf5_hl.so.10 libhdf5_hl.so.10
# ln -s /opt/anaconda2/lib/libopencv_core.so.3.1 libopencv_core.so.3.1
# ln -s /opt/anaconda2/lib/libopencv_highgui.so.3.1 libopencv_highgui.so.3.1
# ln -s /opt/anaconda2/lib/libopencv_imgproc.so.3.1 libopencv_imgproc.so.3.1
# ln -s /opt/anaconda2/lib/libopencv_imgcodecs.so.3.1 libopencv_imgcodecs.so.3.1
# ldconfig

Compile Caffe by multithread. For example, -j8 use 8 threads. (A good choice for the number of threads is the number of cores in your machine)

# make all -j8
# make test -j8
# make runtest -j8

For the last command, it should show PASSED at the end.

Run Samples (Check Points)

Download and create MNIST database

# ./data/mnist/get_mnist.sh
# ./examples/mnist/create_mnist.sh

Run it. With a Titan X, the following script should be finished within 25 seconds.

# ./examples/mnist/train_lenet.sh

Python Interface

Comoplie the Python interface.

# make pycaffe -j8

Install dependency module in Python

# conda install protobuf
# conda install -c https://conda.binstar.org/dougal lmdb

Add Caffe module directory to PYTHONPATH

# vi /etc/profile

Add the following line to the end of /etc/profile

export PYTHONPATH=$PYTHONPATH:/opt/ml-items/caffe-2c34393/python:

Refresh

# source /etc/profile

Check Points

# python

>> import caffe

It should be no error.

Copy mnist_example.py to /opt/ml-items/caffe-2c34393/examples and run it. It should be no error.

# cd /opt/ml-items/caffe-2c34393/examples
# python mnist_example.py

end Check Points



http://www.linjialiang.net/article/view.asp?id=136

http://www.linjialiang.net/article/view.asp?id=135

موافقین ۰ مخالفین ۰ ۹۶/۰۳/۰۷
صالح جمالی

Caffe

MachineLearning

نظرات  (۰)

هیچ نظری هنوز ثبت نشده است

ارسال نظر

ارسال نظر آزاد است، اما اگر قبلا در بیان ثبت نام کرده اید می توانید ابتدا وارد شوید.
شما میتوانید از این تگهای html استفاده کنید:
<b> یا <strong>، <em> یا <i>، <u>، <strike> یا <s>، <sup>، <sub>، <blockquote>، <code>، <pre>، <hr>، <br>، <p>، <a href="" title="">، <span style="">، <div align="">
تجدید کد امنیتی