本节将详细介绍在RK3399的Ubuntu16.04系统中安装caffe
本人使用的是普通的RK3399开发板,安装的是Ubuntu 16.04系统,如果使用的是RK3399 PRO且安装Ubuntu 18.04可以直接sudo apt install caffe-cpu
1.安装caffe依赖包
sudo apt-get install libprotobuf-dev
sudo apt-get install libleveldb-dev
sudo apt-get install libsnappy-dev
sudo apt-get install libopencv-dev
sudo apt-get install libhdf5-serial-dev
sudo apt-get install protobuf-compiler
sudo apt-get install libgflags-dev
sudo apt-get install libgoogle-glog-dev
sudo apt-get install liblmdb-dev
sudo apt-get install libatlas-base-dev
apt-get install --no-install-recommends libboost-all-dev
2.安装git
sudo apt-get install git
3.安装caffe
下载caffe:
git clone http://github.com/BVLC/caffe.git
在caffe文件夹下打开终端:
cp Makefile.config.example Makefile.config
修改Makefile.config文件:
(1)去掉CPU_ONLY := 1前面的#号,取消注释
(2)原来的路径配置:
Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
改为下面的内容,不然make时候会报找不到opencv和hdf5的错,尤其注意PC下为是x86-64-linux-gnu
,这里是ARM,需要改为aarch64-linux-gnu
Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial /opt/Opencv2/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/aarch64-linux-gnu /usr/lib/aarch64-linux-gnu/hdf5/serial /opt/Opencv2/lib
修改完保存退出
编译caffe:
sudo make all
sudo make test
sudo make runtest
成功编译后runtest不会出错
4.编译python接口
安装pip:
sudo apt-get install python-pip
进入/caffe/python
,pip安装caffe环境:
sudo pip install -r requirements.txt
打开配置文件bashrc:
sudo gedit ~/.bashrc
在文件的最后添加路径(每个人路劲不一样,比如我的/home/9tripod/桌面/caffe/python
):
export PYTHONPATH=/home/9tripod/桌面/caffe/python:$PYTHONPATH
返回caffe文件夹,编译python接口:
sudo make pycaffe
验证python接口:
python
import caffe
来源:CSDN
作者:MR_Gaolf
链接:https://blog.csdn.net/MR_Gaolf/article/details/103834830