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

Install MNN deep learning framework on a Raspberry Pi 4.


Introduction.

This page guides you through the installation of Alibaba's MNN 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 MNN library, see https://github.com/alibaba/MNN. Because the installation on a 32-bits operating system is identical to the one on a 64-bits OS, there is no need for sperate instructions.
Dependencies.
The MNN framework has a few dependencies. It requires protobuf. OpenCV is used for building the C++ examples and is not needed for MNN.
# check for updates
$ sudo apt-get update
$ sudo apt-get upgrade
# install dependencies
$ sudo apt-get install cmake wget
$ sudo apt-get install libprotobuf-dev protobuf-compiler

Installation.

With the dependencies installed, the library and converter tools can be built.
# download MNN
$ wget -O mnn.zip https://github.com/alibaba/MNN/archive/master.zip
$ unzip mnn.zip
$ mv MNN-master mnn
$ rm mnn.zip
# common preparation
$ cd mnn
$ ./schema/generate.sh
# install MNN
$ mkdir build
$ cd build
# generate build script
$ cmake -DCMAKE_BUILD_TYPE=Release \
        -DMNN_BUILD_QUANTOOLS=ON \
        -DMNN_BUILD_CONVERTER=ON \
        -DMNN_BUILD_DEMO=ON \
        -DMNN_BUILD_BENCHMARK=ON ..
The MNN building routines are capable of detecting the type of operating system used, as can be seen in the output.

LibBuildMNN

Time to build the library and install it in the appropriate folders.
# build MNN (± 20 min)
$ make -j4
$ sudo make install
MNN_build_rdy

If everything went well, you have the following folders on your Raspberry Pi 4.

MNN_include

MNN_lib

MNN_convert

Please note also the folder with the examples.

MNN_examples

If you like to download some example deep learning models, use the commands below.
# download some models
$ cd ~/mnn
$ ./tools/script/get_model.sh
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