编译Caffe,ubuntu-15.10-desktop-amd64,无Cuda

编译环境

VMWare Workstation 12 Player

ubuntu-15.10-desktop-amd64

cpu 4700mq,给vm分配了6个核心+4GB内存+80GB硬盘

编译步骤

主要参考了caffe官网

http://caffe.berkeleyvision.org/install_apt.html

1. 安装基本包

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

CUDA:由于显卡是750m,不支持cuda,就不弄了

BLAS:sudo apt-get install libatlas-base-dev

Python:sudo apt-get install python-dev

Other:sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev

2. 下载caffe & 配置

直接去github下载最新的caffe:https://github.com/BVLC/caffe 点击Download ZIP按钮即可下载 caffe-master.zip

unzip caffe-master.zip

cd caffe-master

根据官网的指引http://caffe.berkeleyvision.org/installation.html#compilation,复制以及修改Makefile.config文件

cp Makefile.config.example Makefile.config

由于我没有支持cuda的gpu,因此需要将

# CPU_ONLY := 1

这一行取消注释,表明只用CPU进行计算

3. 编译

make all

make test

make runtest

头两个make可以添加 -j6参数以多线程编译,提高效率

最后一个make是跑测试用的,使用多线程不能提高速度

可能遇到的问题

make all的时候,发生错误,错误提示为:

hdf5.h could not be found

1. sudo apt-get install libhdf5-dev

2. 修改Makefile.config文件

INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/

3. 添加link关系

cd /usr/lib/x86_64-linux-gnu

sudo ln -s libhdf5_serial.so.8.0.2 libhdf5.so

sudo ln -s libhdf5_serial_hl.so.8.0.2 libhdf5_hl.so

引用自https://github.com/BVLC/caffe/issues/2347

然后重新编译即可