Install MNN deep learning framework on a Jetson Nano.
This page will guide you through the installation of Alibaba's MNN framework on a Jetson Nano. Because the MNN framework targets mobile devices, like Android phones, it has no CUDA support. However, most Android phones use the Vulkan API for low-level access to their GPU's. The MNN framework cleverly utilizes Vulkan, OpenGL and OpenGL ES routines to accelerate the convolutions of a deep learning model. The Jetson Nano has Vulkan support which MNN will be using. More information about the software structures can be found here and here. The given C ++ code examples are written in the Code::Blocks IDE for the Nano. 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. Perhaps unnecessarily, but the installation is the C ++ version. It is not suitable for Python.
The MNN framework has a few dependencies. It requires protobuf. OpenCV is being used for building the C++ examples and is not needed for MNN. The installation of MNN on a Jetson Nano with a Linux Tegra operating system begins as follows.
# 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
$ sudo apt-get install libglew-dev
Before you can compile the MNN software, there is one thing to be done. The MNN Vulkan interface uses the OpenGL ES 3.0 library. It is a low-level graphics rendering interface for Android. Luckily it is backwards compatible with the version 2.0 library found in the JetPack 4.4 on your Jetson Nano. And, as far as we know, the MNN framework doesn't use any unique version 3.0 calls. It makes it possible to use a symbolic link redirecting libGLES3.0 to libGLES2.0. This strategy works very well and relieves you from a cumbersome installation of version 3.0.
# make symlink
$ sudo ln -s /usr/lib/aarch64-linux-gnu/libGLESv2.so /usr/lib/aarch64-linux-gnu/libGLESv3.so
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
# install MNN
$ mkdir build
$ cd build
# generate build script
$ cmake -DCMAKE_BUILD_TYPE=Release \
Time to build the library and install it in the appropriate folders.
# build MNN (± 25 min)
$ make -j4
$ sudo make install
And after sudo make install.
If everything went well, you have the following folders on your Raspberry Pi 4.
Please note also the folder with the examples.
If you like to download some example deep learning models, use the commands below.
# download some models
$ cd ~/mnn