Caffe安装与初步使用

系统环境

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数据集

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数据集

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

参考资料

在Ubuntu 14.04上安装Caffe

你可能感兴趣的:(Caffe安装与初步使用)