InferModel.configure Segmentation Fault

Using HailoRT4.21, Ubuntu24.04, x86_64

Example Code:

from hailo_platform import VDevice, HailoSchedulingAlgorithm, FormatType, HEF
import numpy as np
from functools import partial
from threading import Thread, Event
import cv2
import time
import faulthandler
faulthandler.enable()

MODEL_RESOLUTION = (224, 224)
MODEL_PATH = "models/objdet.hef"


def async_inference_target(src_callback, dst_callback, stop_event):
    # Create a VDevice
    try:
        params = VDevice.create_params()
        params.scheduling_algorithm = HailoSchedulingAlgorithm.ROUND_ROBIN
        params.group_id = "SHARED"
        params.multi_process_service = False
        with VDevice(params) as vdevice:
            infer_model = vdevice.create_infer_model(MODEL_PATH)
            infer_model.set_batch_size(1)
            infer_model.input().set_format_type(FormatType.UINT8)
            infer_model.output().set_format_type(FormatType.FLOAT32)
        print("VDevice and InferModel created successfully.")
    except Exception as e:
        print(f"Error: {e}")

    with infer_model.configure() as configured_infer_model:
        # Create bindings for it and set buffers
        bindings = configured_infer_model.create_bindings()
        bindings.input().set_buffer(np.empty(infer_model.input().shape).astype(np.uint8))
        bindings.output().set_buffer(np.empty(infer_model.output().shape).astype(np.uint8))
        print("Configured bindings")
....

I get the following output in Python

VDevice and InferModel created successfully.
Fatal Python error: Segmentation fault

Current thread 0x000072851e3bd080 (most recent call first):
File “/home/matrix/depth-anything/.venv/lib/python3.9/site-packages/hailo_platform/pyhailort/pyhailort.py”, line 2870 in configure
File “/home/matrix/depth-anything/detect.py”, line 30 in async_inference_target
File “/home/matrix/depth-anything/detect.py”, line 60 in
Segmentation fault

When using GDB to examine the stack trace I see the following:

[Thread 0x7fffc921f6c0 (LWP 7793) exited] [Thread 0x7fffc9a206c0 (LWP 7792) exited] VDevice and InferModel created successfully. Configuring infer model: <class ‘hailo_platform.pyhailort.pyhailort.InferModel’> [Thread 0x7fffca2216c0 (LWP 7791) exited] Thread 1 “python” received signal SIGSEGV, Segmentation fault. 0x0000000000000000 in ?? () (gdb) bt #0 0x0000000000000000 in ?? () #1 0x00007ffff67b96ac in hailort::VDevice::create_configure_params[abi:cxx11](hailort::Hef&) const () from /lib/libhailort.so.4.21.0 #2 0x00007ffff6a1319d in hailort::InferModelBase::configure() () from /lib/libhailort.so.4.21.0 #3 0x00007ffff7373b9c in ?? () from /home/matrix/depth-anything/.venv/lib/python3.9/site-packages/hailo_platform/pyhailort/_pyhailort.cpython-39-x86_64-linux-gnu.so #4 0x00007ffff736ca4e in ?? () from /home/matrix/depth-anything/.venv/lib/python3.9/site-packages/hailo_platform/pyhailort/_pyhailort.cpython-39-x86_64-linux-gnu.so #5 0x00007ffff73cddd3 in ?? () from /home/matrix/depth-anything/.venv/lib/python3.9/site-packages/hailo_platform/pyhailort/_pyhailort.cpython-39-x86_64-linux-gnu.so #6 0x000000000052f35b in ?? () #7 0x0000000000517a4b in _PyObject_MakeTpCall () #8 0x000000000052d196 in ?? () #9 0x000000000051386f in _PyEval_EvalFrameDefault () #10 0x000000000051f993 in ?? () #11 0x000000000050f1cc in _PyEval_EvalFrameDefault () #12 0x000000000051f993 in ?? () #13 0x000000000050ef2b in _PyEval_EvalFrameDefault () #14 0x000000000050db39 in ?? () #15 0x000000000050d79b in _PyEval_EvalCodeWithName () #16 0x00000000005d7fc7 in PyEval_EvalCode () #17 0x000000000060525b in ?? () #18 0x0000000000601794 in ?? () #19 0x00000000005fc0cd in ?? () #20 0x00000000005fb7c7 in PyRun_SimpleFileExFlags () #21 0x00000000005f89ab in Py_RunMain () #22 0x00000000005cc07d in Py_BytesMain () #23 0x00007ffff7c2a1ca in __libc_start_call_main (main=main@entry=0x5cc040, argc=argc@entry=2, argv=argv@entry=0x7fffffffdc48) at ../sysdeps/nptl/libc_start_call_main.h:58 #24 0x00007ffff7c2a28b in __libc_start_main_impl (main=0x5cc040, argc=2, argv=0x7fffffffdc48, init=, fini=, rtld_fini=, stack_end=0x7fffffffdc38) at ../csu/libc-start.c:360 #25 0x00000000005cbf75 in _start ()

Interestingly, this same code works perfectly fine on my Raspberry pi CM4 running bookworm. Any ideas?

Oh my gosh… This one was due to an indentation error.If you’re seeing this make sure you have your “with” calls nested like this so your vdevice is not out of scope

        with VDevice(params) as vdevice:
            ...

            with infer_model.configure() as configured_infer_model
                ...
1 Like