1.安装依赖
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-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
sudo apt-get install python-skimage
sudo apt-get install python-pip
sudo pip install protobuf
2.安装caffe
2.1下载caffe
git clone https://github.com/BVLC/caffe.git
cd caffe
git checkout ssd
2.2修改配置文件
cp Makefile.config.example Makefile.config
打开Makefile.config修改内容: 去掉# BLAS := atlas、 cudnn := 1 ...
- 若使用cudnn,则将#USE_CUDNN := 1 修改成: USE_CUDNN := 1
- 若使用的opencv版本是3的,则将#OPENCV_VERSION := 3 修改为: OPENCV_VERSION := 3
- 若要使用python接口,则将#WITH_PYTHON_LAYER := 1 修改为: WITH_PYTHON_LAYER := 1
2.3编译
mkdir build
cd build
cmake ..
make all -j4
make install
make runtest -j4
make pycaffe
2.4添加环境变量
sudo gedit /etc/ld.so.conf.d/caffe.conf
添加
/.caffe路径./caffe/build/lib
保存退出
sudo ldconfig
3.可能遇到的问题
3.1python测试时出现“ImportError: No module named caffe”,解决办法:
终端执行:
sudo gedit ~/.bashrc
在最后添加
export PYTHONPATH=~/.caffe路径./caffe/python:$PYTHONPATH
保存并退出,终端继续执行
source ~/.bashrc
3.2出现“ImportError: No module named skimage.io”,解决办法:
sudo apt-get install python-skimage
3.3出现“No module named google.protobuf.internal”,解决办法:
sudo apt-get install python-pip
sudo pip install protobuf