Table of Contents

VIM3 Ubuntu 24.04 Linux Mainline NPU Usage

You need Mainline OS version V1.6.8-240605 or newer.

Now only support MobileNet and SSDLite MobileDet.

Introduction

This documentation will introduce VIM3 NPU usage based on the Open Source NPU driver.

Install Environment

Remove all of # in /etc/apt/sources.list

$ sudo vi /etc/apt/sources.list
$ sudo apt update
$ sudo apt-get -y build-dep mesa
$ sudo apt-get -y install git cmake python3-pip

Download Codes

$ git clone https://gitlab.freedesktop.org/tomeu/mesa.git
$ git checkout teflon-accel

Compile

Demo should run in Python3.10. Install Python3.10 and activate Python3.10 environment. Install Python library in Python3.10 environment and then compile.

$ cd mesa
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get -y install python3.10 python3-pytest python3.10-venv
$ python3.10 -m venv myenv
$ source myenv/bin/activate
$ pip install pycparser mako
$ pip install 'numpy<2'
$ pip install tflite-runtime==2.13.0 pillow
$ meson setup build -Dgallium-drivers=etnaviv -Dvulkan-drivers= -Dteflon=true
$ meson compile -C build

Run

$ wget https://github.com/tensorflow/tensorflow/raw/master/tensorflow/lite/examples/label_image/testdata/grace_hopper.bmp
$ TEFLON_DEBUG=verbose ETNA_MESA_DEBUG=ml_dbgs python3.10 src/gallium/frontends/teflon/tests/classification.py \
                                                          -i ./grace_hopper.bmp -m src/gallium/targets/teflon/tests/mobilenet_v1_1.0_224_quant.tflite \
                                                          -l src/gallium/frontends/teflon/tests/labels_mobilenet_quant_v1_224.txt \
                                                          -e build/src/gallium/targets/teflon/libteflon.so