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
注意:由于网络情况的不同,一次安装可能不能全部安装成功,重复输入上述命令,再次安装(本人同时进行两次,第二次用于确认是否全部安装成功),这里建议大家一次安装一个软件包,便于弄清是那个未安装成功,以节省时间。另需注意,有些会出现无法定位的情况,输入以下命令后再继续安装:sudo apt-get update
3.安装ATLAS,输入下述命令:
sudo apt-get install libatlas-base-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
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.给caffe配置python接口:
使用默认Python来建立pycaffe接口,需要安装: sudo apt-get install python-dev
如果需要Caffe的Python接口,切换到caffe下的python目录下,输入以下命令下载python依赖库(先安装pip):
sudo apt-get install python-pip
for req in $(cat requirements.txt); do pip install $req; done
(注意:ipython已更新为6版本,但与python2.7冲突,但默认安装6,故需在caffe/python/requirements.txt中可进行版本限定,其他软件类同)
修改Makefile.config配置文件:
找到:
# NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.h and numpy/arrayobject.h.
PYTHON_INCLUDE := /usr/include/python2.7 \
/usr/lib/python2.7/dist-packages/numpy/core/include
修改为:
# We need to be able to find Python.h and numpy/arrayobject.h.
PYTHON_INCLUDE := /usr/include/python2.7 \
/usr/local/lib/python2.7/dist-packages/numpy/core/include
测试Caffe的Python接口,切换到caffe/python文件目录下,记录下来当前路径,输入以下命令:
export PYTHONPATH=/path/to/caffe/python:$PYTHONPATH
上面的方法,一旦关闭终端或者打开新终端则失效,如果放到配置文件中,可以永久有效果,命令操作如下:
gedit ~/.bashrc #打开配置文件
export PYTHONPATH=/home/usrname/caffe/python:$PYTHONPATH #配置文件最后写入该路径,本人是export PYTHONPATH=/home/xu/caffe/python:$PYTHONPATH
source ~/.bashrc #生效
8.进行编译
make pycaffe
make all
make test
make runtest
9.耐心等待编译完成
好了,到此为止,Caffe就安装完成了。尽情使用吧!
10.最后验证是否配置成功(类同Theano)
进入python环境,输入:
import caffe
如果没有报错,证明安装成功。恭喜!!!!
————————此文用于记录本人深度学习,谢谢参考。