Install TensorFlow Addons on Raspberry 64 OS - Q-engineering
Q-engineering
Q-engineering
Go to content
images/empty-GT_imagea-1-.png
TensorFlow Addons on Raspberry Pi

Install TensorFlow Addons on Raspberry 64 OS

64-OS TensorFlow 2.4.1

Introduction.

TensorFlow Addons give you additional functionality not yet included in the core of TensorFlow. If it has proven useful, a particular Addon merged into the TensorFlow package. Other algorithms remain in the Addons herd, only appreciated by a select few of the TF-community.

Due to the experimental nature of the package, versions have a short lifespan. Fourteen versions have been released in 2020 alone.
We hope to keep up with the pace. If not, please let us know, and we will try to provide the missing version on our GitHub page.

Because the Addons work entirely in conjuction with TensorFlow, we discuss only the 64-bit version. Installing a 32-bit version of TensorFlow on a Raspberry Pi is a nightmare, with disappointing performances.  Better use the new and much snappier 64-bit operating system on your RPi.

Version check.
Please check your operating system before installing the TensorFlow Addons on your Raspberry 64-bit OS. Run the command uname -a and verify your version with the screen dump below.

VersionCheck_64

You also need to check your C++ compiler version with the command gcc -v. It must also be an aarch64-linux-gnu version, as shown in the screenshot. If you have a 64-bit operating system, but your gcc version is different from the one given above, 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 libraries. Even if you use Python wheels, gcc is called behind the curtains.
Also, note the zram swap size of more than 3 Gbyte after installation according to our instructions.
Tensorflow.
As said, the Addons work with the TensorFlow framework, so you need to have a working TensorFlow version on your system. If required, you can install a recent TensorFlow version according to one of our guides. You can check your TensorFlow version with the different Addons version here.

The wheel.

Once you have TensorFlow up and running, you can install the Addons. The easiest way to install the TensorFlow-Addons is by using the wheel we have placed on our GitHub page. It's the outcome of the time-consuming installation from scratch by Bazel, given in the next paragraph. Please follow the instructions.
# download the wheel
$ wget https://github.com/Qengineering/TensorFlow-Addons-Raspberry-Pi_64-bit/raw/main/tensorflow_addons-0.13.0.dev0-cp37-cp37m-linux_aarch64.whl
# install the wheel
$ sudo -H pip3 install tensorflow_addons-0.13.0.dev0-cp37-cp37m-linux_aarch64.whl
You can now check the installation, as can be seen in the screen dump below.

none


Installation from scratch.

Building the TensorFlow-Addons from scratch is not so difficult. It only takes time to compile all code. In the end, you get the same wheel as we put on GitHub. If you want to save some time, feel free to use this wheel. In case you want to build the Addons yourself, here's the complete guide.
Bazel.
First, you need bazel, a commonly used build tool like CMake. We have already used bazel during the building of TensorFlow from scratch. Please see this paragraph on how to install bazel on your Raspberry Pi 4. To be clear, you only have to install bazel. Once done, you can return to this page again. There is no need to download and install TensorFlow from scratch as described there next.

Building the Addons.

After the installation of bazel, you can download the Addons repo.
Before you start compiling the Addons, you have to modify the configure.py script to set the right environment variables for the bazel build. Another script that needs our attention is build_pip_pkg.sh. Here we must change the 'old' python to python3 to get the wheel generation working.
We have made a pull request to the TensorFlow-Addon community to modify the configure.py and build_pip_pkg.sh for the Raspberry Pi 4 and Jetson Nano. Until they approve the pull, please use the script on our GitHub page. See the following commands.
# get the aadons
$ cd ~
$ git clone --depth=1 https://github.com/tensorflow/addons.git
# get the modified configure script and replace the original one
$ wget https://github.com/Qengineering/TensorFlow-Addons-Raspberry-Pi_64-bit/raw/main/configure.py
$ mv configure.py ./addons/
# get the modified build_pip_pkg.sh script and replace the original one
$ wget https://github.com/Qengineering/TensorFlow-Addons-Raspberry-Pi_64-bit/raw/main/build_pip_pkg.sh
$ mv build_pip_pkg.sh ./addons/build_deps
# symlink the tensorflow lib to /usr/lib
$ sudo ln -s /usr/local/lib/python3.7/dist-packages/tensorflow/python/_pywrap_tensorflow_internal.so /usr/lib/lib_pywrap_tensorflow_internal.so
# the Raspberry Pi 64-bits configuration will be set
$ cd ~/addons
$ python3 ./configure.py
# and start the build
$ bazel clean
$ bazel build build_pip_pkg
# finish with the wheel generation
$ sudo bazel-bin/build_pip_pkg /tmp/tensoraddons_pkg
# install the wheel
$ cd /tmp/tensoraddons_pkg
$ sudo -H pip3 install tensorflow_addons-0.13.0.dev0-cp37-cp37m-linux_aarch64.whl
# you can remove the addons folder, as it is no longer needed
$ sudo rm -rf ~/addons
For your information, we have a small slideshow below that highlights the different steps.
Install 64 OS
Install 32 OS
Raspberry and alt
Raspberry Pi 4
Jetson Nano
images/GithubSmall.png
images/YouTubeSmall.png
images/SDcardSmall.png
Back to content