[Caffe] installation of Caffe instruction book (Linux installation Caffe (without cuda) and Python interface)

Source: Internet
Author: User
Tags intel mkl

installation Caffe Instruction Book

Environment: Linux 64-bit

Video card for Intel + AMD, non-NVIDIA graphics

No GPU

I. Installation Preparation work

1. log in as Administrator

In the top left corner, click on the icon to search for terminal (that is, terminal) and log in as Super Administrator:

Command: sudo su

Input password can be

2. Install Boost

Command: sudo apt-get install Libboost-all-dev

3. Installing BLAS(Intel MKL)

(1) Download Intel MKL Library and install it after decompression

: https://software.intel.com/en-us/intel-mkl/to apply for free software using the school mailbox/research unit address, and receive the serial number and the address of the downloaded software in the mailbox.

Go to/TMP and unzip

Command: TAR–ZXVF l_mkl_11.3.0.109.tgz

(2) Installing the MKL

Command: sudo sh install.sh

4. Dependent Library

Command:

sudo apt-get install Libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev Libhdf5-serial-dev Protobuf-compiler Liblmdb-dev

5. Glog

Command:

wget https://google-glog.googlecode.com/files/glog-0.3.3.tar.gz

Tar zxvf glog-0.3.3.tar.gz

CD glog-0.3.3

sudo sh./configure

sudo make && sudo make install

6. Lib Path

(1) Open/build mkl.conf file

Command: sudo gedit/etc/ld.so.conf.d/mkl.conf

Input content

/opt/intel/lib/intel64

/opt/intel/mkl/lib/intel64

(2) Open/build cuda.conf file

Command: sudo gedit/etc/ld.so.conf.d/cuda.conf

Input content:

/usr/local/cuda/lib64

/usr/local/cuda/lib

(3) Immediate effect

Command: sudo ldconfig

7. Installing protoc-c

Command: sudo apt-get install Protobuf-c-compiler Protobuf-compiler

8. Installing gflags

Command: wget https://github.com/schuhschuh/gflags/archive/master.zip
Unzip Master.zip
CD Gflags-master
mkdir Build && CD Build
Export cxxflags= "-fpic" && cmake. && make verbose=1
Make
sudo make install

9. Installing lmdb

Method One: (Until now, this download is being maintained, so I use the second way)

Command: Git clone git://gitorious.org/mdb/mdb.git
CD Mdb/libraries/liblmdb
Make
sudo make install

Method Two:

(1) Download Lmdb

: Https://github.com/LMDB/lmdb Click on the download on the right, download the ZIP format

(2) Decompression

Command: CD tmp

Unzip Lmdb_mdb.master.zip

CD Lmdb_mdb.master/libraries/liblmdb

Make

sudo make install

installation Caffe

(1) Download Caffe

Command: Git clonegit://github.com/bvlc/caffe.git

(2) Installation Caffe

Command: CD Caffe
CP Makefile.config.example Makefile.config

Two. Compiling:

1. Modify makefile.config three places

cpu_only:= 1 Comment (#) removed

Use_cudnn:=0

Blas Select Mkl

Command: VI makefile.config

At the cursor that needs to be modified, press the INSERT key to modify it (if it is wrong, do not press the left and right arrows, press ESC, then Modify), and press ESC to exit the edit.

If the modification succeeds, save the command:: Wq, do not save the command:: q!

2. compiling

Command: Make all

Make Test

Make Runtest

Three. Running Lenet in Mnist

1. get mnist data First

Command: CD Caffe

./data/mnist/get_mnist.sh

2. Create lenet

Command:./examples/mnist/create_mnist.sh

Note Be sure to run the following command in the root directory of the Caffe, otherwise you will be reported "Build/examples/mnist/convert_mnist_data.bin:not found" error.

3. Train CNN

(1) Modification

If you don't have a GPU, remember to set the Solver_mode in Caffe/examples/mnist/lenet_solver.prototxt to SOLVER_MODE:CPU.

(2) Train CNN to execute in the root directory:

Command:./examples/mnist/train_lenet.sh

Accuracy can reach 0.9912

Four. Install the Python interface

Since Python is 2.7.6 under its own Linux system, it has not been reinstalled. If the version is too old, it is recommended to reinstall it. Reference: http://blog.csdn.net/pan_tian/article/details/7684409

1. Install Pip

sudo apt-get install Python-pippython-dev build-essential

2. Configure the path, edit Makefile.config

Python_include: =/usr/include/python2.7 \
/usr/lib/python2.7/dist-packages/numpy/core/include
Python_lib: =/usr/local/lib


Include_dirs: = $ (python_include)/usr/local/include
Library_dirs: = $ (python_lib)/usr/local/lib/usr/lib

3. Run the following code to install the necessary dependencies:

sudo pip install-r./python/requirements.txt

sudo apt-get install python-numpy python-scipypython-matplotlib python-sklearn python-skimage python-h5py Python-protobufpython-leveldb python-networkx python-nose Python-pandas python-gflags Cythonipython

4. Run in the root directory of the Caffe:

Make Pycaffe

5. If Python path addition fails, consider the following methods: (Small series solved with this method)

Log in with super privileges, set environment variables

Command: sudo gedit/etc/profile

Enter at the bottom of the document: (Hint: The path entered after Pythonpath= is the Caffe path installed under Linux)

Pythonpath=caffe/python: $PYTHONPATH
Export PYTHONPATH

Command: Source/etc/profile

Python

Import Caffe

6.test:

Command: Python draw_net.py <protext> <outfile>

e.g. ./python/draw_net.py./examples/mnist/lenet_train_test.prototxt lenet.png

Note: The Graphviz and Pydot are installed first

Command: sudo apt-getinstall graphviz graphviz-doc

sudo pip install Pydot

Reference Posts:

1.http://www.cnblogs.com/sunshineatnoon/p/4535329.html

2.http://blog.csdn.net/wingfox117/article/details/46278001

3. Sharing of Yuanyuan

[Caffe] installation Caffe instruction book (Caffe (no cuda) and Python interface installed under Linux)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.