安装依赖
sudo apt install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt install --no-install-recommends libboost-all-dev
sudo apt install libgflags-dev libgoogle-glog-dev liblmdb-dev libatlas-base-dev
sudo apt install libgflags-dev libblas-dev liblmdb-dev libgflags-dev
编译
一、去载源码
去github 下载
二、配置
cp Makefile.config.example Makefile.config
如果是CPU模式,则配置为
CPU_ONLY := 1
解决hdf5错误问题
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
三、编译
依次执行命令
make all -j8
make test -j8
make runtest -j8
注意:-j8是指使用8核进行编译,根据配置调整
编译python接口
一、安装依赖
sudo apt install python-pip
sudo apt install python-numpy
sudo apt install gfortran
for req in $(cat python/requirements.txt); do pip install $req; done
sudo pip install -r python/requirements.txt
二、编译
make pycaffe
三、配置环境变量
export PYTHONPATH=/home/ubuntu/caffe/python:$PYTHONPATH
四、测试
运行python
>> import caffe
如果没有报错,说明caffe安装全部完成!