【深度学习】一、Ubuntu16.04 安装配置Caffe

时间:2020-12-12 06:27:05

1 基本信息

本机安装环境是,VMWare Workstation 10 安装64位的虚拟机Ubuntu 16.04

1.1 Ubuntu 系统信息

charles@charlesubuntuserver:~$ cat /etc/issue
Ubuntu 16.04.2 LTS \n \l

charles@charlesubuntuserver:~$ uname -a
Linux charlesubuntuserver 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

1.2 Caffe 地址

https://github.com/BVLC/caffe.git

2 安装过程

2.1 安装依赖

安装这些依赖的过程中,一次安装没有全部安装成功,解决方法是:经过sudo apt-get update之后,再继续安装。

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  
sudo apt-get install libatlas-base-dev  
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev 

2.2 配置及编译Caffe

从git中clone出源码后,修改Makefile.config:

cp Makefile.config.example Makefile.config  
vi 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  

如果是32位的Ubuntu,那么库路径应该是/usr/lib/i386-linux-gnu/hdf5/serial,若不确定,可以find 下libhdf5.a

随后进行编译:

make all  
make test  
make runtest  

参考资料

1) markdown在博客园的使用 : http://www.cnblogs.com/zichi/p/4788229.html
2) Caffe安装教程之Ubuntu16.04:http://blog.csdn.net/oyjxer/article/details/51824254
3) Ubuntu Installation : http://caffe.berkeleyvision.org/install_apt.html
4) Caffe官方教程中译本v1.0 —— CaffeCN社区集体翻译:http://caffecn.cn/?/page/tutorial