caffe(CPU版)安装

2020-03-08  本文已影响0人  ____X

    这是很早以前参考的笔记。
    原链接:https://blog.csdn.net/u014106566/article/details/85179450

一、 安装依赖

1.  sudo apt-get update
2.  sudo apt-get upgrade
3.  sudo apt-get install  -y libopencv-dev
4.  sudo apt-get install -y build-essential cmake git pkg-config
5.  sudo apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler
6.  sudo apt-get install -y liblapack-dev
7.  sudo apt-get install -y libatlas-base-dev
8.  sudo apt-get install -y --no-install-recommends libboost-all-dev
9.  sudo apt-get install -y libgflags-dev libgoogle-glog-dev liblmdb-dev

1.  sudo apt-get install -y python-pip
2.  sudo apt-get install -y python-dev
3.  sudo apt-get install -y python-numpy python-scipy
4.  sudo apt-get install -y python3-dev
5.  sudo apt-get install -y python3-numpy python3-scipy

二、 下载caffe

    使用git进行下载caffe

git clone https://github.com/BVLC/caffe.git

三、 开始安装

1. 进入caffe的python目录下

    如果需要caffe的python接口,切换到caffe下的python目录下,输入以下命令下载python依赖库(先安装pip):

cd caffe/python/
sudo apt-get install python-pip
for req in $(cat requirements.txt); do pip install $req; done
2. 拷贝一个安装配置文件
cp Makefile.config.example Makefile.config
3. 然后修改Makefile.config文件,在caffe目录下打开该文件
sudo gedit Makefile.config
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib

    修改为:

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
4. 修改caffe目录下的Makefile文件
cd caffe

    首先由于Makefile文件为可读文件,所以需要更改权限

chmod a+w Makefile
5.开始编译
make all
make test
make runtest
make pycaffe

    如果所有测试都通过了,则说明安装好了

四、 测试

    测试caffe的python接口,切换到caffe/python文件目录下,输入

Python
import caffe

    如果没有报错,证明安装成功了.

上一篇下一篇

猜你喜欢

热点阅读