Tengine demo failed to run on VIM3 Ubuntu 20.04 firmware 1.0

Hello Khadas,

Please advice:
The tengine demo applications failed to run with the following error:
E [vsi_nn_QuantCheck:423]input_scale[-784.305908] * weight_scale[0.177696] != bias_scale[-139.367645]
E [setup_node:449]Check node[0] CONV2D fail

Notes:

  1. The NPU demo applications was build & run O.K. using the instructions from:
    Description and Usage of aml_NPU_app Code Repository

  2. The tengine demo applications was build by following the instructions from:
    How To Use Tengine SDK
    How To Compile And Run Tengine Demo

Details - build & run of the failed tengine demo

Convert the model to Yolo format

  1. ssh to Ubuntu 18.04 machine
  2. From How To Use Tengine SDK - convert the model on the x64 machine - ​https://docs.khadas.com/vim3/HowToUseTengineSDK.html
  3. Get sources
    workspace=/opt/noveto/src/VIM3.NPU/aml_npu_sdk_6.4.3/workspace
    cd ${workspace}
    git clone https://gitlab.com/khadas/tengine_khadas_sdk.git && cd tengine_khadas_sdk
  4. Get yolov3 original files
    wget --timestamp https://pjreddie.com/media/files/yolov3.weights wget --timestamp
    https://raw.githubusercontent.com/yan-wyb/darknet/master/cfg/yolov3.cfg
  5. Convert and quant
    cd ${workspace}/tengine_khadas_sdk/tengine_tools/quant_tool
    ./quant_tool -f darknet -m $workspace/tengine_khadas_sdk/yolov3.weights
    -p $workspace/tengine_khadas_sdk/yolov3.cfg -o yolov3.tmfile
    -a MINMAX -i $workspace/tengine_khadas_sdk/quant -x 128,128,128
    -y 128,128,128 -z 416,416,3 -c INTERNAL -t UINT8 -n 100
    Output:
    major: 0, minor: 2, revision: 0, seen: 0, transpose: 0
    ===== Create tengine model file done: yolov3_FP32.tmfile and yolov3_UINT8.tmfile

Compile on VIM3 Ubuntu 20.04 machine

  1. From How To Compile And Run Tengine Demo - ​https://docs.khadas.com/vim3/HowToUseTengineApp.html

  2. ssh to VIM3 Ubuntu 20.04 machine with 1.0 kernel package

  3. Check installed versions
    $ uname -a Linux vim3-001 4.9.241 #4 SMP PREEMPT Sun Jan 31 16:54:45 IST 2021 aarch64 aarch64 aarch64 GNU/Linux
    $ g++ --version
    g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
    $ lsb_release -a
    Description: Ubuntu 20.04.2 LTS
    $ dpkg --status aml-npu | grep Version:
    Version: 6.4.3CB-2
    $ dpkg --status tengine-libs | grep Version:
    Version: 1.2-pre

  4. Get sources from GIT
    workspace=/opt/noveto/src/VIM3.NPU/aml_npu_sdk_6.4.3/workspace
    cd ${workspace}
    git clone https://gitlab.com/khadas/tengine_khadas_app.git && cd tengine_khadas_app

  5. Build
    cd ${workspace}/tengine_khadas_app/yolov3-picture
    bash -xv ./build-cv3.sh
    cd ${workspace}/tengine_khadas_app/yolov3-camera
    bash -xv ./build-cv3.sh

  6. Run

  7. Picture application:
    cd ${workspace}/tengine_khadas_app
    ./yolov3-picture/cv3_output/tengine_khadas_yolov3_picture
    -m …/tengine_khadas_sdk/tengine_tools/quant_tool/yolov3_UINT8.tmfile
    -i …/aml_npu_demo_binaries/detect_demo_picture/1080p.bmp

Output:
    tengine-lite library version: TE-BU-P3002-Khadas-v1.0-R20201210
    vsiplugin reshape output tensor addr is 0x55969822b0
    vsiplugin reshape output tensor addr is 0x5596982350
    vsiplugin reshape output tensor addr is 0x55969823f0
    TENGINE_LAYOUT_NCHW goto RELEASE
    E [vsi_nn_QuantCheck:423]input_scale[-784.305908] * weight_scale[0.177696] != bias_scale[-139.367645]
    E [setup_node:449]Check node[0] CONV2D fail Setup graph failure. vsi_exec_graph == NULL                 
    subgraph 0
    prerun failed
    scheduler->prerun failed
    Prerun graph failed
  1. Camera application:
    cd ${workspace}/tengine_khadas_app
    ./yolov3-camera/cv3_output/tengine_khadas_yolov3_camera
    -m …/tengine_khadas_sdk/tengine_tools/quant_tool/yolov3_UINT8.tmfile
    -d /dev/video2

    Output:
    tengine-lite library version: TE-BU-P3002-Khadas-v1.0-R20201210
    vsiplugin reshape output tensor addr is 0x7f9c300b40
    vsiplugin reshape output tensor addr is 0x7f9c300be0
    vsiplugin reshape output tensor addr is 0x7f9c2fed70
    TENGINE_LAYOUT_NCHW goto RELEASE
    E [vsi_nn_QuantCheck:423]input_scale[-784.305908] * weight_scale[0.177696] != bias_scale[-139.367645]
    E [setup_node:449]Check node[0] CONV2D fail
    Setup graph failure.
    vsi_exec_graph == NULL
    subgraph 0 prerun failed
    scheduler->prerun failed
    Prerun graph failed

@GalShalifNoveto

  1. Please check you sisytem version : cat /etc/fenix-release
  2. Where is your yolov3 model file form ?
  1. cat /etc/fenix-release

    PLEASE DO NOT EDIT THIS FILE

    BOARD=VIM3
    VENDOR=Amlogic
    VERSION=1.0
    ARCH=arm64
    INITRD_ARCH=arm64
    INSTALL_TYPE=EMMC
    IMAGE_RELEASE_VERSION=V1.0-210112
    ################ GIT VERSION ################
    UBOOT_GIT_VERSION=khadas-vims-v1.0-release
    LINUX_GIT_VERSION=khadas-vims-v1.0-release
    FENIX_GIT_VERSION=v1.0
    #############################################

  2. The yolov3 model is got from:

Following instructions from https://docs.khadas.com/vim3/HowToUseTengineSDK.html
a. from Get yolov3 original file - download the files:
yolov3.weights
yolov3.cfg - download the RAW version of the GIT text file

b. Convert and quant with:
cd ${workspace}/tengine_khadas_sdk/tengine_tools/quant_tool
./quant_tool -f darknet -m $workspace/tengine_khadas_sdk/yolov3.weights
-p $workspace/tengine_khadas_sdk/yolov3.cfg -o yolov3.tmfile
-a MINMAX -i $workspace/tengine_khadas_sdk/quant -x 128,128,128
-y 128,128,128 -z 416,416,3 -c INTERNAL -t UINT8 -n 100

@GalShalifNoveto OK, I will try it with this relase firmware and faceback there

@GalShalifNoveto I have test it , you should update you system , the last release is 210130

The demo in 210130 works fine ,

2 Likes

Please let me know if “The demo in 210130 works fine” was run on Ubuntu 20.04.

Note:
I had re-installed the VIM3 SBC from scratch with Ubuntu 20.04 - but got the same error:

  1. Start with installing Ubuntu 20.04 from https://dl.khadas.com/Firmware/VIM3/Ubuntu/EMMC/VIM3_Ubuntu-gnome-focal_Linux-4.9_arm64_EMMC_V0.9-20200530.7z
  2. Follow with system update to latest 1.0.2
  3. Run the demo program
  4. Got the exactly same error :frowning:

Summary of my SBC information:
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION=“Ubuntu 20.04.2 LTS”

$ cat /etc/fenix-release

PLEASE DO NOT EDIT THIS FILE

BOARD=VIM3
VENDOR=Amlogic
VERSION=1.0.2
ARCH=arm64
INITRD_ARCH=arm64
INSTALL_TYPE=EMMC
IMAGE_RELEASE_VERSION=V1.0.2-210130
################ GIT VERSION ################
UBOOT_GIT_VERSION=khadas-vims-v1.0.2-release
LINUX_GIT_VERSION=khadas-vims-v1.0.2-release
FENIX_GIT_VERSION=v1.0.2
#############################################

@GalShalifNoveto Did you reboot you system after upgrade ?

Yes.

Status update:
The AMLogic NPU demo is working O.K. - https://docs.khadas.com/vim3/HowToUseAmlNPUApp.html

So I will give-up on the TEngine SDK and will re-write my code to use the AMLogic NPU SDK.

3 Likes