一、本地编译环境
1、更新系统软件包目录
sudo apt update && sudo apt dist-upgrade -y
另外扩展:(看个人需求,自动删除无效依赖包)
sudo apt autoremove -y
2、下载安装依赖库
gcc g++ git make cmake wget python3 python3-dev python3-pip unzip curl(需要编译python2支持库,另外安装python、python-pip和python-dev)
sudo apt install -y gcc g++ make wget cmake python3 unzip patchelf python3-dev python3-pip git
二、源码编译
1. 下载Paddle-Lite 源码
首先下载官方GitHub上的Paddle-Lite源码:
#GitHub加速
git config --global url."https://ghproxy/".insteadOf https://
# 下载 Paddle Lite 源码并切换到发布分支,如 develop
git clone https://github/PaddlePaddle/Paddle-Lite.git
cd Paddle-Lite && git checkout develop
# (可选) 删除 third-party 目录,编译脚本会自动从国内 CDN 下载第三方库文件
rm -rf third-party
注意:在此树莓派4B默认的4线程编译,建议切换成单线程编译,由于设备配置较低导致多线程同步出现编译错误。
export LITE_BUILD_THREADS=1
2. 编译Paddle-Lite 预测库
./lite/tools/build_linux.sh --with_python=ON
上述指令有多种参数配置,可以按照自己的实际需求进行配置:
3. 编译结果
位于Paddle-Lite/build.lite.linux.armv8.gcc/inference_lite_lib.armlinux.armv8生成 Paddle Lite 编译包,文件目录如下:
inference_lite_lib.armlinux.armv8/
├── cxx C++ 预测库和头文件
│ ├── include C++ 头文件
│ │ ├── 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 C++ 预测库
│ └── libpaddle_light_api_shared.so C++ light_api 动态库
│
├── demo C++
│ └── cxx C++ 预测库 demo
│ └── python Python 预测库demo
│
└── python Python 预测库(需要打开with_python选项)
├── install
│ └── dist
│ └── paddlelite-*.whl Python whl包
└── lib
└── lite.so Python 预测库
4. pip3直接安装whl文件
找到python whl包目录,然后直接运行安装命令:
pip3 install *.whl #把*改成编译生成的whl名称
更多推荐
树莓派4B Ubuntu22.4本地编译Paddle-Lite 2.11
发布评论