作者:hahah | 来源:互联网 | 2023-09-02 18:02
第一部分:安装dependenciessudoapt-getinstalllibprotobuf-devlibleveldb-devlibsnappy-devlibopencv-
第一部分: 安装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 install libatlas-base-dev
sudo apt-get install libhdf5-serial-dev
sudo apt-get install python-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
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
sudo pip insall numpy==1.15.0
之后下载源码
git clone https://github.com/BVLC/caffe.git
第二部分:配置
进入caffe目录
cp Makefile.config.example Makefile.config
编辑Makefile.config文件
CPU_ONLY := 1前面的#要去掉.
追加黑体字片段
# 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
里面的python相关的配置要根据自己的环境具体配置
python环境查看方法:
from sysconfig import get_paths
from pprint import pprintinfo = get_paths() # a dictionary of key-paths# pretty print it for now
pprint(info)
{'data': '/usr/local','include': '/usr/local/include/python2.7','platinclude': '/usr/local/include/python2.7','platlib': '/usr/local/lib/python2.7/dist-packages','platstdlib': '/usr/lib/python2.7','purelib': '/usr/local/lib/python2.7/dist-packages','scripts': '/usr/local/bin','stdlib': '/usr/lib/python2.7'}
第三部分:编译
make pycaffe
make all
make test
make runtest
--结果显示ALL TESTS PASSED就安装好了, 只需要再加上一个PYTHONPATH;
第四部分:测试使用
export PYTHONPATH=/home/houlin/code/caffe/python:$PYTHONPATH
python
>>> import caffe
>>> caffe.set_mode_cpu()