Open5

VisionFive2 - 202409 Release Memo

nb.onb.o

Install dependencies

$ sudo apt install git
$ sudo apt install cmake
$ sudo apt install build-essential
nb.onb.o

TensorFlow Lite v2.18.0

Build from source

Build tensorflow lite

$ git clone -b v2.18.0 https://github.com/tensorflow/tensorflow.git
$ mkdir tflite_build
$ cd tflite_build/
$ cmake \
    ../tensorflow/tensorflow/lite/ \
    -DTFLITE_ENABLE_GPU=ON \
    -DXNNPACK_ENABLE_RISCV_VECTOR=OFF
$ cmake --build . -j3

Build benchmark_model

$ cmake --build . -j3 -t benchmark_model

Benchmark efficientdet-lite0

Model

Benchmark
use_xnnpack=true

$ tools/benchmark/benchmark_model --graph=/home/user/efficientdet-tflite-lite0-detection-default-v1.tflite --use_xnnpack=true
INFO: STARTING!
INFO: Log parameter values verbosely: [0]
INFO: Graph: [/home/user/efficientdet-tflite-lite0-detection-default-v1.tflite]
INFO: Signature to run: []
INFO: Use xnnpack: [1]
INFO: Loaded model /home/user/efficientdet-tflite-lite0-detection-default-v1.tflite
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
INFO: XNNPACK delegate created.
INFO: Explicitly applied XNNPACK delegate, and the model graph will be partially executed by the delegate w/ 13 delegate kernels.
INFO: The input model file size (MB): 4.56118
INFO: Initialized session in 106.77ms.
INFO: Running benchmark for at least 1 iterations and at least 0.5 seconds but terminate if exceeding 150 seconds.
INFO: count=1 curr=2290337

INFO: Running benchmark for at least 50 iterations and at least 1 seconds but terminate if exceeding 150 seconds.
INFO: count=50 first=2246807 curr=2240072 min=2239525 max=2246807 avg=2.24022e+06 std=1101

INFO: Inference timings in us: Init: 106770, First inference: 2290337, Warmup (avg): 2.29034e+06, Inference (avg): 2.24022e+06
INFO: Note: as the benchmark tool itself affects memory footprint, the following is only APPROXIMATE to the actual memory footprint of the model at runtime. Take the information at your discretion.
INFO: Memory footprint delta from the start of the tool (MB): init=12.375 overall=34.918

use_gpu=true

$ tools/benchmark/benchmark_model --graph=/home/user/efficientdet-tflite-lite0-detection-default-v1.tflite --use_gpu=true
INFO: STARTING!
INFO: Log parameter values verbosely: [0]
INFO: Graph: [/home/user/efficientdet-tflite-lite0-detection-default-v1.tflite]
INFO: Signature to run: []
INFO: Use gpu: [1]
INFO: Loaded model /home/user/efficientdet-tflite-lite0-detection-default-v1.tflite
INFO: Created TensorFlow Lite delegate for GPU.
INFO: GPU delegate created.
INFO: Loaded OpenCL library with dlopen.
ERROR: Following operations are not supported by GPU delegate:
CUSTOM TFLite_Detection_PostProcess: TFLite_Detection_PostProcess
266 operations will run on the GPU, and the remaining 1 operations will run on the CPU.
INFO: Loaded OpenCL library with dlopen.
INFO: Initialized OpenCL-based API.
INFO: Created 1 GPU delegate kernels.
INFO: Explicitly applied GPU delegate, and the model graph will be partially executed by the delegate w/ 1 delegate kernels.
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
INFO: The input model file size (MB): 4.56118
INFO: Initialized session in 7825.8ms.
INFO: Running benchmark for at least 1 iterations and at least 0.5 seconds but terminate if exceeding 150 seconds.
INFO: count=1 curr=1979369

INFO: Running benchmark for at least 50 iterations and at least 1 seconds but terminate if exceeding 150 seconds.
INFO: count=50 first=464837 curr=452761 min=442457 max=464837 avg=451032 std=5484

INFO: Inference timings in us: Init: 7825797, First inference: 1979369, Warmup (avg): 1.97937e+06, Inference (avg): 451032
INFO: Note: as the benchmark tool itself affects memory footprint, the following is only APPROXIMATE to the actual memory footprint of the model at runtime. Take the information at your discretion.
INFO: Memory footprint delta from the start of the tool (MB): init=80.0547 overall=118.449

Build pip package

Install dependencies

$ sudo apt install swig libjpeg-dev zlib1g-dev python3-dev python3-numpy
$ sudo apt install python3-pybind11
$ sudo apt install python3-setuptools
$ sudo apt install python3-wheel
$ sudo apt install python3-pip

Modify build_pip_package_with_cmake.sh

$ git diff tensorflow/lite/tools/pip_package/build_pip_package_with_cmake.sh
diff --git a/tensorflow/lite/tools/pip_package/build_pip_package_with_cmake.sh b/tensorflow/lite/tools/pip_package/build_pip_package_with_cmake.sh
index aa5b9eb737e..a2021db19a3 100755
--- a/tensorflow/lite/tools/pip_package/build_pip_package_with_cmake.sh
+++ b/tensorflow/lite/tools/pip_package/build_pip_package_with_cmake.sh
@@ -134,6 +134,7 @@ case "${TENSORFLOW_TARGET}" in
     cmake \
       -DCMAKE_C_FLAGS="${BUILD_FLAGS}" \
       -DCMAKE_CXX_FLAGS="${BUILD_FLAGS}" \
+      -DXNNPACK_ENABLE_RISCV_VECTOR=OFF \
       "${TENSORFLOW_LITE_DIR}"
     ;;
 esac

Build pip package and install

$ cd tensorflow/
$ export BUILD_NUM_JOBS=3
$ ./tensorflow/lite/tools/pip_package/build_pip_package_with_cmake.sh
$ pip3 install --user --break-system-packages /home/user/tensorflow/tensorflow/lite/tools/pip_
package/gen/tflite_pip/python3/dist/tflite_runtime-2.18.0-cp311-cp311-linux_riscv64.whl

Operation check

$ cd
$ git clone git@github.com:NobuoTsukamoto/tflite-cv-example.git
$ cd tflite-cv-example/benchmark/
$ python3 benchmark_tflite.py --model ~/efficientdet-tflite-lite0-detection-default-v1.tflite --thread 4
Model name: /home/user/efficientdet-tflite-lite0-detection-default-v1.tflite, param num_threads: 4, delegate: None
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
Interpreter:  1 320 320 3
First Inference : 3034.57 ms
  step 100/1000, iter_time(ms)=2985
  step 200/1000, iter_time(ms)=2982
  step 300/1000, iter_time(ms)=2967
  step 400/1000, iter_time(ms)=2982
  step 500/1000, iter_time(ms)=3010
  step 600/1000, iter_time(ms)=2956
  step 700/1000, iter_time(ms)=3007
  step 800/1000, iter_time(ms)=2974
  step 900/1000, iter_time(ms)=3090
  step 1000/1000, iter_time(ms)=3002
/home/user/tflite-cv-example/benchmark/benchmark_tflite.py:92: DeprecationWarning: the `interpolation=` argument to percentile was renamed to `method=`, which has additional options.
Users of the modes 'nearest', 'lower', 'higher', or 'midpoint' are encouraged to review the method they used. (Deprecated NumPy 1.22)
  np.percentile(iter_times, q=99, interpolation="lower") * 1000
  images/sec: 0
  99th_percentile(ms): 3081.69
  total_time(s): 2994.3
  latency_mean(ms): 2994.33
  latency_median(ms): 2986.29
  latency_min(ms): 2953.85
nb.onb.o

DepthAI

Error occurs when installing Pip Package

$ sudo wget -qO- https://docs.luxonis.com/install_dependencies.sh | bash
$ python3 -m pip install --break-system-packages  depthai

...
Could not import depthai: /tmp/pip-install-mu9padvs/depthai_e2c449e202cb49319f7c09ca6411984d/build/lib.linux-riscv64-cpython-311/depthai.cpython-311-riscv64-linux-gnu.so: undefined symbol: __atomic_exchange_1
...

Build DepthAI Python Library

Clone depthai-python repository.

$ cd ~
$ mkdir depthai
$ git clone https://github.com/luxonis/depthai-python.git
$ cd depthai-python
$ git submodule update --init --recursive
  1. depthai-python/CMakeLists.txt
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7ac7877fc..9abe274c6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -477,6 +477,7 @@ target_link_libraries(${TARGET_CORE_NAME}
         spdlog::spdlog
         ZLIB::zlib
         ghcFilesystem::ghc_filesystem
+       atomic
 )

 if(DEPTHAI_ENABLE_CURL)
  1. depthai-python/depthai-core/CMakeLists.txt
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7ac7877fc..9abe274c6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -477,6 +477,7 @@ target_link_libraries(${TARGET_CORE_NAME}
         spdlog::spdlog
         ZLIB::zlib
         ghcFilesystem::ghc_filesystem
+       atomic
 )

 if(DEPTHAI_ENABLE_CURL)

Changing runlevel

During the build, an error occurs due to insufficient memory. To avoid the error, change the run level and build in CUI mode.

$ sudo systemctl set-default multi-user.target
$ sudo reboot

Build Wheel

python3 -m pip wheel . -w wheelhouse

Install

$ pip3 install --break-system-packages ./wheelhouse/depthai-2.28.0.0.dev0+50f509bdd29c89817cf546bd8eb2c104f083f82f-cp311-cp311-linux_riscv64.whl

Change runlevel.

$ sudo systemctl set-default multi-user.target
$ sudo reboot

Install examples

cd examples

OpenCV is already installed, so it will be bypassed.

diff --git a/examples/install_requirements.py b/examples/install_requirements.py
index 69cbfd59..ff0d37be 100755
--- a/examples/install_requirements.py
+++ b/examples/install_requirements.py
@@ -43,7 +43,7 @@ import find_version

 # 3rdparty dependencies to install
 DEPENDENCIES = ['pyyaml', 'requests']
-requireOpenCv = True
+requireOpenCv = False
 thisPlatform = platform.machine()
 if thisPlatform == "aarch64":
     # try to import opencv, numpy in a subprocess, since it might fail with illegal instruction
@@ -71,7 +71,7 @@ ARTIFACTORY_URL = 'https://artifacts.luxonis.com/artifactory/luxonis-python-snap
 in_venv = getattr(sys, "real_prefix", getattr(sys, "base_prefix", sys.prefix)) != sys.prefix
 pip_call = [sys.executable, "-m", "pip"]
 pip_installed = True
-pip_install = pip_call + ["install", "-U"]
+pip_install = pip_call + ["install", "-U", "--break-system-packages"]
 pip_package_install = pip_install + ["--prefer-binary"]

 try:
@@ -130,6 +130,7 @@ else:


 # Install python dependencies
+print(DEPENDENCIES)
 python_dependencies_cmd = [*pip_package_install, *DEPENDENCIES]
 if args.dry_run:
     prettyPrint(python_dependencies_cmd)
user@starfive:~/depthai/depthai-python$
Broadcast message from user@starfive (Sun 2024-11-17 12:35:21 UTC):

Setup.

$ python3 install_requirements.py

Operation check