注:本文适合python2.7 opencv2.4.x,之前学习其他DL框架时安装过CUDA的情况
一、安装必要的依赖库
sudo apt-get update sudo apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev hdf5-tools libhdf5-serial-dev protobuf-compiler gfortran libjpeg62 libfreeimage-dev libatlas-base-dev git python-dev python-pip libgoogle-glog-dev libbz2-dev libxml2-dev libxslt-dev libffi-dev libssl-dev libgflags-dev liblmdb-dev python-yaml
二、下载caffe并安装python依赖库
cd ~ git clone https://github.com/BVLC/caffe.git cd caffe cat python/requirements.txt | xargs -L 1 sudo pip install
三、增加符号链接
sudo ln -s /usr/include/python2.7/ /usr/local/include/python2.7 sudo ln -s /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/ /usr/local/include/python2.7/numpy
四、生成Makefile.config并修改
生成文件:cp Makefile.config.example Makefile.config
将标签为“INCLUDE_DIRS”和“LIBRARY_DIRS”修改如下:
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 /usr/lib/x86_64-linux-gnu/hdf5/serial
特别提醒:将WITH_PYTHON_LAYER := 1 前面的#去掉,有些程序(比如fast-rcnn)会在proto里面写入type: "Python",去掉这行的注释才能正常运行
五、编译caffe
make pycaffe make all make test make runtest
六、将PYTHONPATH写入.bashrc中
echo 'export PYTHONPATH=/home/<USER>/caffe/python' >> ~/.bashrc source ~/.bashrc
七、在eclipse中使用
将路径/home/<user>/caffe/python加入pydev插件中的python系统路径
附录:
http://caffe.berkeleyvision.org/
http://caffe.berkeleyvision.org/tutorial/
https://zhuanlan.zhihu.com/p/22129880
http://installing-caffe-the-right-way.wikidot.com/start
https://github.com/BVLC/caffe/wiki/Ubuntu-16.04-or-15.10-Installation-Guide
原文链接:https://www.f2er.com/ubuntu/353396.html