Before you begin

To work through this guide, you need a Raspberry Pi 4 with Raspbian 10 operating system.

You must install the following software on the Raspberry Pi:

These software packages might have further prerequisites. See the installation instructions for each package for more information.

For complete and up-to-date installation information, always refer to the previous README links. However, for your convenience, we provide, at the end of this section, a list of the commands that we used to install Arm NN and PyArmNN.

PyArmNN object recognition uses the sample application. Follow the instructions in PyArmNN Object Detection Sample Application to install and build

Arm NN C++ API object recognition uses the Arm NN object_detection_example executable. Follow the instructions in Object Detection Example to install and build object_detection_example.

The installation links referenced earlier use OpenCV 3. If you want to use OpenCV 4 instead, you can follow the instructions in Install OpenCV 4 on your Raspberry Pi. The sample application in this guide needs to have the WITH_GTK and WITH_OPENCL flags enabled. In Step #5: CMake and compile OpenCV 4 for your Raspberry Pi, enable the flags using the following command:


Update your PYTHONPATH environment variable to include /usr/local/python/cv2/python-<version>.

The following code builds Arm NN and installs PyArmNN:

  • Code to build Arm NN and install PyArmNN
    # Increase virtual memory swapfile allocation
    sudo vi /etc/dphys-swapfile
    # Find the following line:
    #    CONF_SWAPSIZE=100
    # Change this line to:
    #    CONF_SWAPSIZE=1024
    sudo /etc/init.d/dphys-swapfile stop
    sudo /etc/init.d/dphys-swapfile start
    # Install SCONS and CMAKE
    sudo apt-get update
    sudo apt-get install scons
    sudo apt-get install cmake
    # Install Arm NN prerequisites
    mkdir armnn-tflite && cd armnn-tflite
    export BASEDIR=`pwd`
    git clone
    git clone
    tar xf boost_1_64_0.tar.bz2
    git clone -b v3.5.0
    git clone
    cd tensorflow/
    git checkout 590d6eef7e91a6a7392c8ffffb7b58f2e0c8bc6b
    git clone
    cd $BASEDIR/ComputeLibrary
    scons extra_cxx_flags="-fPIC" benchmark_tests=0 validation_tests=0 neon=1
    cd $BASEDIR/boost_1_64_0
    ./b2 --build-dir=$BASEDIR/boost_1_64_0/build toolset=gcc link=static cxxflags=-fPIC --with-filesystem --with-test --with-log --with-program_options install --prefix=$BASEDIR/boost
    cd $BASEDIR/protobuf
    git submodule update --init --recursive
    sudo apt-get install autoconf
    sudo apt-get install libtool
    ./configure --prefix=$BASEDIR/protobuf-host
    make install
    cd $BASEDIR/tensorflow
    ../armnn/scripts/ ../tensorflow-protobuf
    cd $BASEDIR
    git clone
    cd $BASEDIR/flatbuffers
    cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
    #Install SWIG
    sudo apt-get install libpcre3 libpcre3-dev
    cd $BASEDIR
    mkdir swig
    cd swig
    chmod 777 swig-4.0.2.tar.gz
    tar -xzvf swig-4.0.2.tar.gz
    cd swig-4.0.2/
    ./configure --prefix=/home/pi/armnn-tflite/swigtool/
    sudo make
    sudo make install
    sudo vi /etc/profile
    # Add the following lines to /etc/profile
    #   export SWIG_PATH=/home/pi/armnn-tflite/swigtool/bin
    #   export PATH=$SWIG_PATH:$PATH
    source /etc/profile
    # Build Arm NN
    cd $BASEDIR/armnn
    mkdir build
    cd build
    cmake .. -DARMCOMPUTE_ROOT=$BASEDIR/ComputeLibrary
    -DPROTOBUF_ROOT=$BASEDIR/protobuf-host -DBUILD_TF_LITE_PARSER=1 -DTF_LITE_GENERATED_PATH=$BASEDIR/tensorflow/tensorflow/lite/schema
    cp $BASEDIR/armnn/build/*.so $BASEDIR/armnn/
    cd /home/pi/armnn-tflite/armnn/src/dynamic/sample
    mkdir build
    cd build
    cmake -DBOOST_ROOT=$BASEDIR/boost  -DBoost_SYSTEM_LIBRARY=$BASEDIR/boost/lib/libboost_system.a
    -DARMNN_PATH=$BASEDIR/armnn/ ..
    # Install PYARMNN
    # Following instructions for "Standalone build" from:
    export SWIG_EXECUTABLE=$BASEDIR/swigtool/bin/swig
    export ARMNN_INCLUDE=$BASEDIR/armnn/include/
    export ARMNN_LIB=$BASEDIR/armnn/build/
    cd $BASEDIR/armnn/python/pyarmnn
    sudo apt-get install python3.6-dev build-essential checkinstall libreadline-gplv2-dev
    libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev
    python3 clean --all
    python3 -v
    python3 build_ext --inplace
    python3 sdist
    python3 bdist_wheel
    pip3 install dist/pyarmnn-21.0.0-cp37-cp37m-linux_armv7l.whl 
    sudo pip3 install opencv-python== 
    sudo apt-get install libcblas-dev
    sudo apt-get install libhdf5-dev
    sudo apt-get install libhdf5-serial-dev
    sudo apt-get install libatlas-base-dev
    sudo apt-get install libjasper-dev 
    sudo apt-get install libqtgui4 
    sudo apt-get install libqt4-test
Previous Next