系統(tǒng)環(huán)境
Ubuntu 14.04
安裝依賴庫
sudo apt-get install libatlas-base-dev
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev libhdf5-serial-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev protobuf-compiler
編譯安裝Caffe
# 源碼下載
git clone https://github.com/BVLC/caffe.git
cd caffe
cp Makefile.config.example Makefile.config
# 修改Makefile.config文件,選擇CPU或GPU模式
vi Makefile.config
# 編譯安裝
make all
make pycaffe
# 安裝后的測試
make test
make runtest
安裝過程中numpy報錯,解決方法:
# 安裝python-numpy
sudo apt-get install python-numpy
# python命令行交互
python
import numpy as npnp.get_include()
exit()
# 重新編譯安裝
make pycaffe
Caffe初步使用
1. MNIST數(shù)據(jù)集
cd caffe
sh data/mnist/get_mnist.sh
sh examples/mnist/create_mnist.sh
vi examples/mnist/lenet_solver.prototxt
# 修改 solver_mode 為 CPU
sh examples/mnist/train_lenet.sh
2. CIFAR-10數(shù)據(jù)集
cd caffe
sh data/cifar10/get_cifar10.sh
cd examples/cifar10/create_cifar10.sh
vi examples/cifar10/cifar10_quick_solver.prototxt
# 修改 solver_mode 為 CPU
sh examples/cifar10/train_quick.sh