2015年6月3日 星期三

Setup Caffe from scratch

Introduction

Caffe is a deep learning framework made with expression, speed, and modularity in mind. It is developed by the Berkeley Vision and Learning Center (BVLC) and by community contributors.

Installation on Ubuntu 12.04 / 14.04

Use the script to install Caffe's requirements 
$ git clone https://gist.github.com/tzutalin/b24937905a2480da1723 
$ sh b24937905a2480da1723/installCaffeDep.sh

If you would like to install Caffe's requirement manually or install CUDA depedencies, please refer to http://caffe.berkeleyvision.org/install_apt.html

Get Caffe source and compile it

Clone the source
$ git clone https://github.com/BVLC/caffe.git

After cloning, confing Makefile.config for Makefile
$ cp Makefile.config.example Makefile.config
$ vi Makefile.config
For CPU-only Caffe, uncomment CPU_ONLY := 1 in Makefile.config.

Start compiling
$ make -j 8 all ; make -j 8 test ; make -j 8 runtest ; make pycaffe ; make distribute 
My Makefile.config's screenshot is as bellow. I uncomment CPU_ONLY := 1



Run and test Caffe

Test whether caffe can run or not, use benchmarking cmd as bellos 
$ cd caffe 
$ build/tools/caffe time --model=models/bvlc_alexnet/deploy.prototxt

Run Caffe python
The search path can be manipulated from within a Python program as the variable sys.path.
$ echo PYTHONPATH=[/to/your/path]/caffe/python/:$PYTHONPATH > ~/.bashrc

Try to run classifiy_test.py
$ cd [/to/your/path]/caffe/example 
$ git clone https://gist.github.com/912d1774d96266c4e76b.git 
$ python classify_test.py

If using default python(Python 2.7.6), might need the following dependencies 
$ sudo apt-get install python-scipy python-skimage libqt4-core libqt4-gui libqt4-dev libzmq-dev ; sudo pip install -U scikit-image; sudo pip install pyzmq; sudo pip install protobuf; sudo pip install pygments 


References

Install Intel MKL and other BLAS for Caffe
http://tzutalin.blogspot.tw/2015/06/blas-atlas-openblas-and-mkl.html
Using Caffe with Eclipse
http://tzutalin.blogspot.tw/2015/05/caffe-on-ubuntu-eclipse-cc.html
Manual Install Caffe
http://caffe.berkeleyvision.org/install_apt.html
Instant way to use Caffe
http://nbviewer.ipython.org/github/BVLC/caffe/blob/master/examples/00-classification.ipynb

沒有留言:

張貼留言