Skip to content

Build Larq Compute Engine for ARM

This page descibes how to build Larq Compute Engine (LCE) binaries for 32-bit, as well as 64-bit ARM-based systems. Bazel is the primary build system for LCE and can be used to cross-compile binaries for ARM architectures directly from the host. To natively build on an ARM system, we provide a solution based on the CMake build system.


Although the Raspberry Pi 3 and Raspberry Pi 4 have 64-bit CPUs, the default version of Raspberry Pi OS (previously known as Raspbian) is 32-bit. In order to use the optimized 64-bit kernels of LCE on a Raspberry Pi, the 64-bit version should be used, see here under 'Raspberry Pi OS (64-bit)'.

This leaves us with two main ways to build LCE binaries, which we recommend in the following order:

  1. To cross-compile LCE from a host machine, see "Cross-compiling with Bazel".
  2. To natively compile LCE, see "Building with CMake".

This guide will show you how to build the LCE example program. See here to find out how you can create your own LCE inference binary.

For cross-compiling on a Mac host, a Docker image is required. Please see setting up Docker for instructions on setting up the Docker container, and then follow continue the steps here.

To cross-compile the LCE example for ARM architectures, the bazel target needs to be built with the --config=rpi3 (32-bit ARM) or --config=aarch64 (64-bit ARM) flag. For example, to build the example for 64-bit ARM systems, run the following command from the LCE root directory:

bazel build --config=aarch64 //examples:lce_minimal

To build the LCE benchmark tool, build the bazel target //larq_compute_engine/tflite/benchmark:lce_benchmark_model

The resulting binaries will be stored at bazel-bin/examples/lce_minimal and bazel-bin/larq_compute_engine/tflite/benchmark/lce_benchmark_model. You can copy these to your ARM machine and run them there.

To build LCE with CMake, first clone the Larq Compute Engine repository and make sure the tensorflow submodule is loaded:

git submodule update --init

To natively build the LCE library and C++ example programs, first you need to install the compiler toolchain on your target device.

On Debian based systems like a Raspberry Pi board with Raspberry Pi OS (previously known as Raspbian), run the following command:

sudo apt-get install cmake build-essential

On an Arch based system like a Raspberry Pi board with Manjaro operating system, run the following command instead:

sudo pacman -S base-devel cmake

You should then be able to natively compile LCE by running the following from the LCE root directory:

cmake -S . -B build
cmake --build build

Here 'build' is the name of the out-of-source build directory chosen, which will have all the intermediate and resulting files. Here you can find the example program example and benchmark program lce_benchmark_model.