当前位置:网站首页>树莓派4B编译paddlelite(详细步骤2022年)
树莓派4B编译paddlelite(详细步骤2022年)
2022-04-22 04:28:00 【shier_smile】
文章目录
这几天在树莓派上使用paddlelite部署paddlepaddle模型,
大大小小的报错能遇到坑的我应该全部都踩了个变
1.开发板环境
硬件:树莓派4B, 系统:raspberrypi 5.10.103-v7l+ 1529 SMP Tue Mar 8 12:24:00 GMT 2022 armv7l GNU
2.编译环境
使用本机docker环境给树莓派编译paddlelite,不建议使用树莓派自身编译,速度慢,而且bug多
也不建议使用自身电脑环境进行编译,因为cmake版本不同带来的openml_cxx不存在问题,和g+±arm-linux-gnueabihf版本等版本问题很烦。
本机环境: Linux shier 5.17.1-arch1-1 1 SMP PREEMPT Mon, 28 Mar 2022 20:55:33 +0000 x86_64 GNU/Linux
docker版本:Docker version 20.10.14, build a224086349
3.步骤
1.拉取官方docker 镜像
# 官方镜像
docker pull paddlepaddle/paddle-lite:2.0.0_beta
# 创建、并进入容器
sudo docker run -it \
--name paddlelite_docker \
--net=host \
paddlepaddle/paddle-lite /bin/bash
(这里不选择挂载本机内的paddlelite文件)
2.克隆paddlelite
在docker中克隆paddlelite
git clone https://github.com/PaddlePaddle/Paddle-Lite.git
# 如果没有梯子就
git clone https://gitee.com/paddlepaddle/paddle-lite.git
注意一下从github clone下来的文件为Paddle-Lite,从gitee上的是paddle-lite
cd Paddle-Lite
3.选择版本
git checkout release/v2.0.0 (这个版本要使用编译出来的python的话没有whl文件,只有.so文件)
git checkout release/v2.10(这个正常,2.11也正常)
ok, 最基本的东西准备完了
官方的docker镜像中没有python3,需要自己手动装一个。
一般使用python3.7, 因为树莓派开发板上一般也是这个版本的python,让版本对应
3.1安装python3.7
先安装以下几个依赖环境。
apt update
apt install zlib*
apt install libffi-dev
apt install openssl openssl-dev
apt install patchelf
下载python
cd ~
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
解压python
tar -zxvf Python-3.7.0.tgz
创建python文件夹(因为是docker环境,后续可以删除,自己随便创一个就完了)
mkdir /usr/lib/python3.7
进入python目录,设置启动ssl
cd Python-3.7.0
./configure --prefix=/usr/lib/python3.7 -with-ssl-default-suites=openssl
编译安装
make && make install
安装完成后
删除环境中原有的python2链接,建立新的软链接
rm /usr/bin/pip
rm -f /usr/bin/python
ln -s /usr/lib/python3.7/bin/python3.7 /usr/bin/python3
ln -s /usr/lib/python3.7/bin/pip3.7 /usr/bin/pip3
ln -s /usr/bin/pip3 /usr/bin/pip
ln -s /usr/bin/python3 /usr/bin/python
安装完成,检查一下,查看版本是否对应
python --version
pip list
编译paddlelite需要numpy和wheel,安装(可以换源再进行安装)
换源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
安装
pip install numpy
pip install wheel
4. 编译paddle-lite
如果需要编译产生whl文件的化需要进行修改Paddle-Lite文件夹中的/lite/tools/build_linux.sh文件
vim ./lite/tools/build_linux.sh
在如图所在位置添加

-DPYTHON_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-DPYTHON_LIBRARY=$(python -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))")
因为不加上进行编译时会产生
Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)_错误
如果是使用release/v2.0.0版本的化不一样
位置:


进行编译(官网有,这里同时也给出)
./lite/tools/build_linux.sh --arch=armv8 --with_python=ON
其他参数选择
--arch: (armv8|armv7|armv7hf) arm版本,默认为armv8
--toolchain: (gcc|clang) 编译器类型,默认为gcc
--with_extra: (OFF|ON) 是否编译OCR/NLP模型相关kernel&OP,默认为OFF,只编译CV模型相关kernel&OP
--with_python: (OFF|ON) 是否编译python预测库, 默认为 OFF
--python_version: (2.7|3.5|3.7) 编译whl的Python版本,默认为 None
--with_cv: (OFF|ON) 是否编译CV相关预处理库, 默认为 OFF
--with_log: (OFF|ON) 是否输出日志信息, 默认为 ON
--with_exception: (OFF|ON) 是否在错误发生时抛出异常,默认为 OFF
如果选择release/v2.0.0,命令为
./lite/tools/build.sh --arm_os=armlinux --arm_abi=armv8 --arm_lang=gcc --build_python=ON full_publish
5.编译完成
在buildxxxxxxxxxx.gcc文件夹下会产生inferxxx文件夹(release/v2.10版本)
目录结构
.
|-- bin
| |-- benchmark_bin
| `-- test_model_bin |-- cxx | |-- include | | |-- paddle_api.h | | |-- paddle_image_preprocess.h | | |-- paddle_lite_factory_helper.h | | |-- paddle_place.h | | |-- paddle_use_kernels.h | | |-- paddle_use_ops.h | | `-- paddle_use_passes.h
| `-- lib | |-- liblite_pybind.so | |-- libpaddle_api_full_bundled.a | |-- libpaddle_api_light_bundled.a | |-- libpaddle_full_api_shared.so | `-- libpaddle_light_api_shared.so
|-- demo
| |-- cxx
| | |-- mobilenetv1_full
| | | |-- CMakeLists.txt
| | | |-- build.sh
| | | `-- mobilenet_full_api.cc | | `-- mobilenetv1_light
| | |-- CMakeLists.txt
| | |-- build.sh
| | `-- mobilenet_light_api.cc | `-- python
| |-- mobilenetv1_full_api.py
| `-- mobilenetv1_light_api.py `-- python
|-- install
| |-- build
| | |-- bdist.linux-x86_64
| | |-- lib
| | | `-- paddlelite | | | |-- __init__.py | | | `-- lite.so
| | `-- scripts-3.7 | | `-- paddle_lite_opt
| |-- dist
| | `-- paddlelite-a949e21-cp37-cp37m-linux_x86_64.whl | |-- libs | |-- lite | | |-- __init__.py | | |-- lite.so | | `-- paddle_lite_opt
| |-- paddlelite.egg-info
| | |-- PKG-INFO
| | |-- SOURCES.txt
| | |-- dependency_links.txt
| | `-- top_level.txt | `-- setup.py
`-- lib `-- lite.so
6. 安装
6.1 将文件从docker中拷贝出来
docker cp paddlelite_docker:文件 本机文件名
6.2 树莓派安装whl文件
pip install 文件名 就可以了。
使用
将whl文件拷贝至树莓派中,并直接使用pip install 文件名就完成了。
按照此流程一般情况下不会出错,由于篇幅问题,具体报错,和解决方法将在下一篇博客中给出
版权声明
本文为[shier_smile]所创,转载请带上原文链接,感谢
https://blog.csdn.net/m0_57459724/article/details/124209377
边栏推荐
- 06-Datetimes
- WebSocket学习
- L1-050 penultimate string (15 points)
- L1-048 matrix a multiplied by B (15 points)
- 04-Functions
- H7-TOOL发布固件V2.15, 脱机烧录增加瑞萨,合泰以及IS25WP全系列SPI FLASH等(2022-04-14)
- Interpretation of asterisk source code (I: basic introduction and chan_sip code analysis)
- Mysql中的Decimal类型是什么?
- 毕设-SSM校园二手书籍销售系统+论文
- 腾讯 csig 面试简述(已通过)
猜你喜欢

Matplotlib draw 3dbox

How to solve the problem that the table association is not displayed when importing SQL from powerdesipowerdesigner

LeetCode 63. Different paths II

02-SparkSQL

Sr-te policy (Cisco) -- supplement

Tensorflow error: returned a result with an error set solution

02 - sparksql
![[concurrent programming 043] how to solve the problems of CAS and ABA?](/img/bd/8638aa75d7d3b237d792a201e68c0f.png)
[concurrent programming 043] how to solve the problems of CAS and ABA?

LeetCode_矩形_困难_391.完美矩形

毕设-SSM校园二手书籍销售系统+论文
随机推荐
The core of improving data utilization efficiency in the transportation industry is to do a good job in data exchange and sharing
01-Read&Write
Why can sqlmap run the issue table but not the fields
【近日力扣】(位运算合集)不用加减乘除做加法+只出现一次的数字+只出现一次的数字 II+只出现一次的数字 III
03-DataFrame & Column
Pgpool II 4.3 Chinese Manual - introductory tutorial
L3-022 地铁一日游 (30 分)【floyd+dfs】
DNS domain name system - directory service of the Internet
QT used in vs 2019
L1-052 2018 we want to win (5 points)
[concurrent programming 043] how to solve the problems of CAS and ABA?
PHP excel import time format conversion
Keras deep learning practice (2) -- using keras to construct neural network
Search content warehousing
使用 nohup 命令将程序挂载在后台执行
Rsync remote synchronization
Browser overview local cache cookies, etc
Oracle password expiration problem, set never expire
What level have you learned from your pointer? Eight pointer questions let you deepen your understanding of pointer (Part 2) - O -
Iptables usage