TF lite segmentation fault

Which system do you use? Android, Ubuntu, OOWOW or others?

Hardware: Khadas VIM3
OS: Ubuntu 24.04 (Linux Khadas 5.15.137 #1.7.4 SMP PREEMPT Wed Apr 23 10:46:01 CST 2025 aarch64 aarch64 aarch64 GNU/Linux)
ARM NN: v24.11
Python version: 3.10.18

Please describe your issue below:

I’ve tried multiple combinations of python versions, ARM NN versions, even switched to the new python package ai-edge-litert instead of tflite-runtime, but I always get a segmentation fault when loading the model.
I followed the exact steps in this tutorial to set things up, but still getting the segfault: VIM3/3L TFLite Delegate [Khadas Docs]

Post a console log of your issue below:

(venv) khadas@Khadas:~/git/armnn_tflite/mobilenet_v1  (main):
$ python3 run_inference.py 
Info: ArmNN v34.0.0
Segmentation fault

Hello @Electr1

Do you have any suggestions?

1 Like

Hi @erikh

Not sure what the source of the error is but I will try to replicate the issue and try to provide some solution.

Cheers

@erikh I checked on my side and i couldn’t replicate this issue, but i did have to slightly modify the installation procedure but it did yield a functional result:

For reference the image I used was: https://dl.khadas.com/products/vim3/firmware/ubuntu/generic/ubuntu-24.04/vim3-ubuntu-24.04-gnome-linux-5.15-fenix-1.7.3-241129.img.xz

(work) khadas@Khadas:~/armnn_tflite/mobilenet_v1$ date
Wed Jun 18 07:13:13 PM UTC 2025
(work) khadas@Khadas:~/armnn_tflite/mobilenet_v1$ uname -a
Linux Khadas 5.15.137 #1.7.3 SMP PREEMPT Fri Nov 29 11:58:51 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux
(work) khadas@Khadas:~/armnn_tflite/mobilenet_v1$ python3 run_inference.py 
Info: ArmNN v34.0.0
Info: Initialization time: 20.07 ms.
INFO: TfLiteArmnnDelegate: Added backend CpuAcc
INFO: TfLiteArmnnDelegate: Created TfLite ArmNN delegate.
Info: ArmnnSubgraph creation
Info: Parse nodes to ArmNN time: 2.02 ms
Warning: The first available preferred backend: CpuAcc, does not have FP16 support. The FP16 turbo mode option will be disable. It will run using FP32.
Info: Optimize ArmnnSubgraph time: 3.36 ms
Info: Load ArmnnSubgraph time: 9.32 ms
Info: Overall ArmnnSubgraph creation time: 14.96 ms

Info: Execution time: 115.51 ms.
853
Info: Shutdown time: 0.67 ms.

NOTE: When installing the pip packages inside the virtual env it was done in a way to satisfy the dependency versions (this may be need to be updated in the docs, I am not sure as I didn’t pay attention to what broken in between):

$ pip3 install opencv-python
$ pip3 install pillow tflite-runtime librosa
$ pip3 install numpy==1.26.2

Likewise:

>>> PIL.__version__
'11.2.1'
>>> cv2.__version__
'4.11.0'
>>> numpy.__version__
'1.26.2'
>>> librosa.__version__
'0.11.0'

If you are able to replicate it likewise but still face issues, let me know.

Cheers :wink:

1 Like

Thank you for taking the time to try and replicate this. I checked which image I used and that one is slightly newer (vim3-ubuntu-24.04-server-linux-5.15-fenix-1.7.4-250423-emmc.img).

One additional question before I try it with the image you used: what python version did you use? The default one in that image, or did you install an older version?

I had to used python3.10 which is only available from the deadsnakes ppa (python backports)

Thank you for your quick responses!

I see you only enabled the CpuAcc as backend in run_inference.py. In original example is only GpuAcc enabled as backend, and that’s where my issue is coming from. When I only enable the CpuAcc, it works just fine.
Here’s are all the steps I took to end up with the segmentation fault.

opencv-python==4.11.0.86
pillow==11.2.1
tflite-runtime
librosa==0.11.0
numpy==1.26.2
  • Running the mobilenet inference I don’t get the segmentation fault, but a log line about not able to find any graphics library that is needed to utilize the GPU (GpuAcc is the only backend that is enable by default in the armnn_tflite repo mobilnet example).
$  python run_inference.py 
Info: ArmNN v34.0.0
Couldn't find any of the following OpenCL library: libOpenCL.so libGLES_mali.so libmali.so 
Info: Initialization time: 8.51 ms.
INFO: TfLiteArmnnDelegate: Requested unknown backend GpuAcc
Traceback (most recent call last):
  File "/home/khadas/git/armnn_tflite/venv/lib/python3.10/site-packages/tflite_runtime/interpreter.py", line 166, in load_delegate
    delegate = Delegate(library, options)
  File "/home/khadas/git/armnn_tflite/venv/lib/python3.10/site-packages/tflite_runtime/interpreter.py", line 104, in __init__
    raise ValueError(capture.message)
ValueError: TfLiteArmnnDelegate: No known backend specified.

- During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/khadas/git/armnn_tflite/mobilenet_v1/run_inference.py", line 42, in <module>
    armnn_delegate = tflite.load_delegate(
  File "/home/khadas/git/armnn_tflite/venv/lib/python3.10/site-packages/tflite_runtime/interpreter.py", line 168, in load_delegate
    raise ValueError('Failed to load delegate from {}\n{}'.format(
ValueError: Failed to load delegate from ./libarmnnDelegate.so.29
TfLiteArmnnDelegate: No known backend specified.
Info: Shutdown time: 0.02 ms.
  • When I run clinfo it says that there are no platforms available which suggests that the mali drivers are not installed.
$ clinfo
Number of platforms                               0

ICD loader properties
  ICD loader Name                                 OpenCL ICD Loader
  ICD loader Vendor                               OCL Icd free software
  ICD loader Version                              2.3.2
  ICD loader Profile                              OpenCL 3.0
  • I proceeded to follow the instructions on VIM3/3L OpenCL [Khadas Docs]. After running all the setup commands, I ran clinfo again. I do not post the whole output, since this would be very long. The output now shows that there’s a platform available:
$ clinfo
Number of platforms                               1
  Platform Name                                   Portable Computing Language
  Platform Vendor                                 The pocl project
  Platform Version                                OpenCL 3.0 PoCL 5.0+debian  Linux, None+Asserts, RELOC, SPIR, LLVM 16.0.6, SLEEF, POCL_DEBUG
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_icd cl_pocl_content_size
  Platform Extensions with Version                cl_khr_icd                                                       0x400000 (1.0.0)
                                                  cl_pocl_content_size                                             0x400000 (1.0.0)
  Platform Numeric Version                        0xc00000 (3.0.0)
  Platform Extensions function suffix             POCL
  Platform Host timer resolution                  0ns

  Platform Name                                   Portable Computing Language
Number of devices                                 1
  Device Name                                     cpu--cortex-a53
  Device Vendor                                   ARM
  Device Vendor ID                                0x13b5
  Device Version                                  OpenCL 3.0 PoCL HSTR: cpu-aarch64-unknown-linux-gnu-(null)
  Device Numeric Version                          0xc00000 (3.0.0)
  Driver Version                                  5.0+debian
  Device OpenCL C Version                         OpenCL C 1.2 PoCL
  ...
  • When I now run the inference again, the segfault returns:
$ python run_inference.py 
Info: ArmNN v34.0.0
Segmentation fault

Conclusion: It looks like the install of graphics libraries isn’t entirely correct, since clinfo shows only the CPU as platform and I cannot use the ARM NN delegate once I followed the setup instructions on the official OpenCL page of Khadas.

Am I doing something wrong? Did I miss another setup page or something like that?

@erikh It might be due to the GPU firmware.

I am not sure if it’s only these two, maybe @numbqq can verify once

linux-gpu-mali-wayland_1.4-r44p0-202311_arm64.deb
linux-gpu-mali-gbm_1.2-r44p0-202311_arm64.deb

You should be able to download and install these deb packages to fix gpu openCL, and subsequently the error should go away (hopefully)

Also did you check journalctl -xe/ dmesg for any clues ?

I installed the two packages, and now its working! Thank you very much!

$ python run_inference.py 
Info: ArmNN v34.0.0
Info: Initialization time: 429.10 ms.
INFO: TfLiteArmnnDelegate: Added backend GpuAcc
INFO: TfLiteArmnnDelegate: Created TfLite ArmNN delegate.
Info: ArmnnSubgraph creation
Info: Parse nodes to ArmNN time: 15.06 ms
Info: Optimize ArmnnSubgraph time: 3.70 ms
Info: Load ArmnnSubgraph time: 6854.06 ms
Info: Overall ArmnnSubgraph creation time: 6873.48 ms

Info: Execution time: 131.37 ms.
853
Info: Shutdown time: 0.82 ms.

For the people reading this and don’t know how to download and install those packages:

wget -O linux-gpu-mali-wayland_1.4-r44p0-202311_arm64.deb https://dl.khadas.com/repos/vim3-5.15/pool/main/l/linux-gpu-mali-wayland/linux-gpu-mali-wayland_1.4-r44p0-202311_arm64.deb
wget -O linux-gpu-mali-gbm_1.2-r44p0-202311_arm64.deb https://dl.khadas.com/repos/vim3-5.15/pool/main/l/linux-gpu-mali-gbm/linux-gpu-mali-gbm_1.2-r44p0-202311_arm64.deb

sudo dpkg -i linux-gpu-mali-gbm_1.2-r44p0-202311_arm64.deb 
sudo dpkg -i linux-gpu-mali-wayland_1.4-r44p0-202311_arm64.deb 
1 Like