1.安装环境配置:
~$sudo apt-get update
~$sudo apt-get install python-pip python-dev python-numpy
~$sudo apt-get install python-numpy python-scipy python-matplotlib python-sklearn python-skimage python-h5py python-protobuf python-leveldb python-networkx python-nose python-pandas python-gflags Cython ipython
~$sudo apt-get install gfortran graphviz
~$sudo apt-get install protobuf-c-compiler protobuf-compiler
2.在caffe/python 下有一个requirement.txt,里面有所需要安装的所有库。
cd caffe/python
for req in $(cat requirements.txt); do pip install $req; done
3.编译
cd ~/caffe
sudo make pycaffe -j8
但我在第一次执行时出错了,说是好多引用找不到。后来,打开了sudo gedit /etc/profile 在后面加了个几个路径,再执行就可以正常安装了,路径如下:
export PYTHONPATH=$PYTHONPATH:/home/gjh/caffe/python
使上述更改生效
$ source /etc/profile
4.测试pycaffe
$ Python
Python 2.7.13 |Anaconda, Inc.| (default, Sep 22 2017, 00:47:24)
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import caffe