Install Paddle Lite on Raspberry Pi 4 - Q-engineering
Q-engineering
Q-engineering
Go to content
images/empty-GT_imagea-1-.png
Install Paddle Lite on Raspberry Pi 4

Install Paddle Lite deep learning framework on a Raspberry Pi 4.

Paddle 2.0.0

Introduction.

This page will guide you through the installation of the Baidu's Paddle Lite framework on a Raspberry Pi 4. The given C ++ code examples are written in the Code::Blocks IDE for the Raspberry Pi 4. We only guide you through the basics, so in the end, you can build your application. For more information about the Paddle Lite library, see: https://github.com/PaddlePaddle/Paddle-Lite or the Chinese tutorial https://paddle-lite.readthedocs.io/zh/latest/. Perhaps unnecessarily, but the installation is the C ++ version. It is not suitable for Python.

We have used Paddle Lite version 2.6.3 in our examples. Since October 2020, Paddle has released 2.7.0. This version support not all deep learning models of previous versions. For example, the model used in the Face Mask Detection cannot longer be used. Therefore we keep using version 2.6.3, untill compatabity issues are solved.
Dependencies.
The Paddle Lite framework has almost no dependencies. OpenCV would be useful, but it is not even necessary. We used it because most of our software uses OpenCV one way or the other.

Version check.
Please check your operating system before installing Paddle Lite on your Raspberry Pi 4. Run the command uname -a and verify your version with the screen dump below.

Version_32_64

In case of a 64-bit operating system, please check also your C++ compiler with the command gcc -v. It must also be an aarch64-linux-gnu version. In case of a different gcc version, reinstall the whole operating system with the latest version. The guide is found here: Install 64 bit OS on Raspberry Pi 4. You must have a 64-bit C ++ compiler as we are going to build the Paddle Lite libraries.
Also note the zram swap size of more than 3 Gbyte after installation according to our instructions.

VersionCheck_64


Raspberry Pi 32-bit OS.

Installation.

Due to incompatibility between the CPU (armv8) and the compiler (arm-linux-gnueabihf), Paddle-Lite cannot be installed on a Raspberry Pi 4 with a 32-bit operating system. The generated library uses registers (VFPV3) missing in the armv8. Replacing a compiler can be a real nightmare. You can install Paddle-Lite on a Raspberry Pi 3, or better, take a new SD card and install the latest Raspberry 64-bit OS.
For those with a Raspberry Pi 3, install OpenCV first, if not already installed. The installation guide is here and takes about an hour.
The entire installation of the latest version of Paddle Lite (v2.6.3) on a Raspberry with a 32-bit operating system (Raspbian) is as follows.
Raspberry Pi 3 only !
# check for updates
$ sudo apt-get update
$ sudo apt-get upgrade
# install dependencies
$ sudo apt-get install cmake wget
# download Paddle Lite version 2.6.3 as version 2.7.0 has backward compatibily issues.
$ wget -O paddle.zip https://github.com/PaddlePaddle/Paddle-Lite/archive/v2.6.3.zip
$ unzip paddle.zip
$ mv Paddle-Lite-2.6.3 Paddle-Lite
$ rm paddle.zip
# install Paddle Lite
$ cd Paddle-Lite
# build 32-bit Paddle Lite
$ ./lite/tools/build.sh \
  --build_cv=ON \
  --build_extra=ON \
  --arm_os=armlinux \
  --arm_abi=armv7hf \
  --arm_lang=gcc \
  tiny_publish
# copy the headers and library to /usr/local/
$ sudo mkdir -p /usr/local/lib/paddle-lite
$ sudo cp -r build.lite.armlinux.armv7hf.gcc/inference_lite_lib.armlinux.armv7hf/cxx/include /usr/local/include/paddle-lite
$ sudo cp -r build.lite.armlinux.armv7hf.gcc/libpaddle_api_light_bundled.a /usr/local/lib/paddle-lite/libpaddle_api_light_bundled.a

Raspberry Pi 64-bit OS.

Installation.

Install OpenCV first if it is not already installed. The installation guide is here and takes about an hour.
The entire installation of latest version of Paddle Lite (v2.6.3) on a Raspberry with a 64-bit operating system is as follows.
# check for updates (64-bit OS is still under development!)
$ sudo apt-get update
$ sudo apt-get upgrade
# install dependencies
$ sudo apt-get install cmake wget
# download Paddle Lite version 2.6.3 as version 2.7.0 has backward compatibily issues.
$ wget -O paddle.zip https://github.com/PaddlePaddle/Paddle-Lite/archive/v2.6.3.zip
$ unzip paddle.zip
$ mv Paddle-Lite-2.6.3 Paddle-Lite
$ rm paddle.zip
# install Paddle Lite
$ cd Paddle-Lite
# build 64-bit Paddle Lite (±1 hour)
$ ./lite/tools/build.sh \
  --build_cv=ON \
  --build_extra=ON \
  --arm_os=armlinux \
  --arm_abi=armv8 \
  --arm_lang=gcc \
  tiny_publish
# copy the headers and library to /usr/local/
$ sudo mkdir -p /usr/local/lib/paddle-lite
$ sudo cp -r build.lite.armlinux.armv8.gcc/inference_lite_lib.armlinux.armv8/cxx/include /usr/local/include/paddle-lite
$ sudo cp -r build.lite.armlinux.armv8.gcc/libpaddle_api_light_bundled.a /usr/local/lib/paddle-lite/libpaddle_api_light_bundled.a

If everything went well, you will get the following output.

Paddle_inc

Paddle_lib

Please note also the folder with the examples.

Paddle_Examples

Deep learning software for Raspberry Pi
Deep learning examples for Raspberry Pi
Install 64 OS
Install 32 OS
Raspberry and alt
Raspberry Pi 4
Jetson Nano
Back to content