Ubuntu16.04上caffe环境的搭建
前言:
环境准备:
机械化安装:
1.准备ubuntu系统
2.系统安装完成后,打开命令行控制台,输入以下命令,安装基本依赖(General dependencies)。
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
3.安装ATLAS,输入下述命令:
sudo apt-get install libatlas-base-dev
4.安装剩余依赖:
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
5.clone caffe的代码
sudo apt-get install git
git clone https://github.com/BVLC/caffe.git
6.修改Makefile.config:
cp Makefile.config.example Makefile.config
gedit Makefile.config
找到#CPU_ONLY := 1,取消注释(我们设置为CPU模式)
找到
# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
修改为
# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial
7.编译
make all
make test
make runtest
8.等待编译完成
9.测试
搭建好环境之后当然要用数据测试一下:
sh data/mnist/get_mnist.sh
sh examples/mnist/create_mnist.sh
vim examples/mnist/lenet_solver.prototxt
把lenet_solver.prototxt里面的solver_mode 改为 CPU。因为我们还没装GPU,暂时只使用CPU就好了。
然后我们运行脚本:
./examples/mnist/train_lenet.sh
这个时候,如果成功的话,就能跑起来了。