前提
已經(jīng)安裝好Anaconda、opencv2.4.8以及dlib
正文
- 安裝依賴庫(一):
$ sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
$ sudo apt-get install --no-install-recommends libboost-all-dev
- 安裝BLAS:
$ sudo apt-get install libatlas-base-dev
可以安裝OpenBLAS 或 MKL,以提升CPU性能,但是要修改caffe中Makefile文件…
- 安裝依賴庫(二):
$ sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
- 下載Caffe
$ cd ~
$ git clone git://github.com/BVLC/caffe.git
- 編譯Caffe
$ cd ~/caffe
$ cp Makefile.config.example Makefile.config
- 修改Makefile.config文件:去掉CPU_ONLY:= 1的注釋
$ make all
$ make test
$ make runtest
存在問題解決
安裝glog/gflags/lmdb
- 安裝glog
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
./configure
make
sudo make install
- 安裝gflags
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
- 安裝lmdb
git clone https://github.com/LMDB/lmdb
cd lmdb/libraries/liblmdb
make
sudo make install
- 安裝glog
glog安裝由于無google訪問權(quán)限薪捍,需離線下載安裝就好
make sudo make install
- 安裝lmdb
runtest報(bào)錯(cuò):../../build/examples/lenet/convert_mnist_data.bin: error while loading shared libraries: libglog.so.0: cannot open shared object file: No such file or directory
解決,在runtest之前修改路徑如下:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
配置pycaffe
- 安裝依賴庫:
$ sudo apt-get install python-numpy python-scipy python-matplotlib python-sklearn python-skimage python-h5py python-protobuf python-leveldb python-networkx python-nose python-pandas python-gflags Cython ipython
$ sudo apt-get install protobuf-c-compiler protobuf-compiler
- 編譯
$ cd ~/caffe
$ make pycaffe
- 添加~/caffe/Python到$PYTHONPATH:
$ sudo gedit /etc/profile
- 末尾添加:
export PYTHONPATH=/實(shí)際path/caffe/python:$PYTHONPATH
$ source /etc/profile
- 測(cè)試是否可以引用:
$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import caffe