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

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

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/.
Dependencies.
The Paddle Lite framework has almost no dependencies. OpenCV would be useful, but it is not even necessary.

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.1) on a Raspberry with a 32-bit operating system (Raspbian) is as follows.
# check for updates
$ sudo apt-get update
$ sudo apt-get upgrade
# install dependencies
$ sudo apt-get install cmake wget
# download Paddle Lite
$ wget https://github.com/PaddlePaddle/Paddle-Lite/archive/v2.6.1.zip
$ unzip v2.6.1.zip
# install Paddle Lite
$ rm v2.6.1.zip
$ mv Paddle-Lite-2.6.1 Paddle-Lite
$ cd Paddle-Lite
# build 32-bit Paddle Lite
$ ./lite/tools/build.sh \
  --build_extra=ON \
  --arm_os=armlinux \
  --arm_abi=armv7hf \
  --arm_lang=gcc \
  tiny_publish
# copy the headers and library to /usr/local/
$ sudo mkdir /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/inference_lite_lib.armlinux.armv7hf/cxx/lib /usr/local/lib/paddle-lite

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.1) 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
$ wget https://github.com/PaddlePaddle/Paddle-Lite/archive/v2.6.1.zip
$ unzip v2.6.1.zip
# install Paddle Lite
$ rm v2.6.1.zip
$ mv Paddle-Lite-2.6.1 Paddle-Lite
$ cd Paddle-Lite
# build 64-bit Paddle Lite
$ ./lite/tools/build.sh \
  --build_extra=ON \
  --arm_os=armlinux \
  --arm_abi=armv8 \
  --arm_lang=gcc \
  tiny_publish
# copy the headers and library to /usr/local/
$ sudo mkdir /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/inference_lite_lib.armlinux.armv8/cxx/lib /usr/local/lib/paddle-lite

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
Raspberry and alt
Install 32 OS
Raspberry Pi 4
Install 64 OS
Back to content