Tic商业评论

关注微信公众号【站长自定义模块】,定时推送前沿、专业、深度的商业资讯。

 找回密码
 立即注册

QQ登录

只需一步,快速开始

微信登录

微信扫码,快速开始

  • QQ空间
  • 回复
  • 收藏

在树莓派 4 上安装 Caffe

lijingle 环境搭建 2022-1-25 20:55 2795人围观

介绍
本页将介绍在 Raspberry Pi 4 上安装 Caffe。给定的 C++ 代码示例是在适用于 Raspberry Pi 4 的 Code::Blocks IDE 中编写的。我们只介绍基础知识。 有关 Caffe 的更多信息,请参阅:https://caffe.berkeleyvision.org/。 你的 Raspberry Pi 拥有哪种操作系统并不重要。 在安装过程中,你可以从一系列配置模板中选择你的操作系统。

依赖
Caffe 框架对其他库有一些依赖项。 我们假设你已经根据我们的指南在你的 Raspberry Pi 上安装了 OpenCV。 如果没有,最好先做。
$ sudo apt-get install cmake git unzip 
$ sudo apt-get install libgoogle-glog-dev libgflags-dev
$ sudo apt-get install libprotobuf-dev libleveldb-dev liblmdb-dev
$ sudo apt-get install libsnappy-dev libhdf5-serial-dev protobuf-compiler
$ sudo apt-get install --no-install-recommends libboost-all-dev
$ sudo apt-get install libatlas-base-dev libopenblas-dev
$ sudo apt-get install the python3-dev python3-skimage
$ sudo -H pip3 install pydot
$ sudo apt-get install graphviz

下载caffe
当所有需要的库都安装好后,就可以下载 Caffe 了。
下载来自 WeiLui89 的 Caffe。 与原来的 Caffe 不同,这个版本支持 SSD 操作。 WeiLui 是 Single
 Shot MultiBox Detector 的原始开发者之一。 有关详细信息,请参阅他的文章。
此外,我们还为 Raspberry Pi 和 Ubuntu 添加了一些额外的 Makefile 脚本。下面是caffe连接。
链接:https://pan.baidu.com/s/1fKhZBU6A4J4Y3TWAYojS8g 
提取码:j0le

编译 Caffe。
我们创建了几个配置文件。 在大多数情况下,配置会立即生效,不会出错。 选择合适的并开始构建 Caffe。
 如果构建失败,请参阅 Caffe 配置页面。
Raspberry 64-bit
$ cd ~/caffe
# Raspberry Pi with 64-bit OS
$ cp Makefile.config.cp37_aarch64-linux-gnu_example Makefile.config
# Start the build
$ make clean
$ make all -j4
$ make test -j4
$ make runtest -j4

Raspberry 32-bit
$ cd ~/caffe
# Raspberry Pi with 32-bit OS (Raspbian)
$ cp Makefile.config.cp37_arm-linux-gnueabihf_example Makefile.config
# Start the build
$ make clean
$ make all -j4
$ make test -j4
$ make runtest -j4

Raspberry Ubuntu 20.04
$ cd ~/caffe
# Raspberry Pi with Ubuntu 20.04
$ cp Makefile.config.cp38_aarch64-linux-gnu_example Makefile.config
# Start the build
$ make clean
$ make all -j4
$ make test -j4
$ make runtest -j4

Raspberry Ubuntu 18.04
$ cd ~/caffe
# Raspberry Pi with Ubuntu 18.04
$ cp Makefile.config.cp36_aarch64-linux-gnu_example Makefile.config
# Start the build
$ make clean
$ make all -j4
$ make test -j4
$ make runtest -j4

希望你会在 make runtest 之后看到下面的屏幕,表明一切顺利。


你可能需要编译一些额外的软件。 首先,有pycaffe。 如果你想在 Python 3 中运行 Caffe,你将需要

这个接口。否则,Caffe 将只能从命令行或 C++ 程序中运行。 有关更多信息,请参阅原始 Caffe 文档。 你还可以在 MATLAB 中运行 Caffe。 这次你需要制作matcaffe。 但是,在成功构建 matcaffe 之前,需

要设置 Makefile.config 中的某些行。 在 pytest 之后,你的屏幕如下所示。

# Assuming you're still in ~/caffe
$ make pycaffe
$ make pytest


你的 Caffe 安装已准备好在具有 OpenCV 4.4.0 和 Python 3 的 Raspberry Pi 4 上运行。 你需要将 Caffe 添加到您的 PYTHONPATH 中。 这可以在 ~/.bashrc 或 ~/.profile 中完成。

我们选择 bashrc。 打开文件并在文件的最后添加行 export PYTHONPATH="$PYTHONPATH:$HOME/caffe/python" 。

像往常一样使用 Crtl+X、Y 和 Enter 保存并关闭。 最后,现在可以从任何位置导入 Caffe,如屏幕截图所示。

$ cd ~
$ sudo nano ~/.bashrc
# at the end of the file add the next line
export PYTHONPATH="${PYTHONPATH}:$HOME/caffe/python"
# save and close with
Ctrl+X, Y, Enter



如果你在 Raspberry Pi 4 上构建 Caffe 时遇到任何问题,请参阅配置页面。



路过

雷人

握手

鲜花

鸡蛋
我有话说......
电话咨询: 135xxxxxxx
关注微信