[deepstream-test.py] Error: Could not map EglImage from NvBufSurface for nvinfer on headless orin

Please provide complete information as applicable to your setup.

• Hardware Platform: Jetson Orin
• DeepStream Version: 6.3
• JetPack Version 5.1.2 (r35.4.1)
• TensorRT Version: 8.5.2-1+cuda11.4
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type: Bug
Getting the following output on the deepstream_test_1.py demo (updated to use fakesink since it’s headless):

Creating Pipeline

Creating Source
 
Creating H264Parser 

Creating Decoder

nvbufsurftransform: Could not get EGL display connection
Playing file ../../../../samples/streams/sample_720p.h264 
Adding elements to Pipeline

Linking elements in the Pipeline 
Starting pipeline

Opening in BLOCKING MODE 
0:00:00.277767335 113117     0x28c87cc0 WARN                    v4l2 gstv4l2object.c:4561:gst_v4l2_object_probe_caps:<nvv4l2-decoder:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
0:00:00.277800071 113117     0x28c87cc0 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0x28401100 Failed to determine interlace mode
0:00:00.277817607 113117     0x28c87cc0 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0x28401100 Failed to determine interlace mode
0:00:00.277834600 113117     0x28c87cc0 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0x28401100 Failed to determine interlace mode
0:00:00.277850088 113117     0x28c87cc0 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0x28401100 Failed to determine interlace mode
0:00:00.285341102 113117     0x28c87cc0 WARN                 nvinfer gstnvinfer.cpp:679:gst_nvinfer_logger:<primary-inference> NvDsInferContext[UID 1]: Warning from NvDsInferContextImpl::initialize() <nvdsinfer_context_impl.cpp:1174> [UID = 1]: Warning, OpenCV has been deprecated. Using NMS for clustering instead of cv::groupRectangles with topK = 20 and NMS Threshold = 0.5
0:00:03.134913375 113117     0x28c87cc0 INFO                 nvinfer gstnvinfer.cpp:682:gst_nvinfer_logger:<primary-inference> NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::deserializeEngineAndBackend() <nvdsinfer_context_impl.cpp:1988> [UID = 1]: deserialized trt engine from :/opt/nvidia/deepstream/deepstream-6.3/samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine
INFO: [Implicit Engine Info]: layers num: 3
0   INPUT  kFLOAT input_1         3x368x640
1   OUTPUT kFLOAT conv2d_bbox     16x23x40
2   OUTPUT kFLOAT conv2d_cov/Sigmoid 4x23x40

0:00:03.297684007 113117     0x28c87cc0 INFO                 nvinfer gstnvinfer.cpp:682:gst_nvinfer_logger:<primary-inference> NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:2091> [UID = 1]: Use deserialized engine model: /opt/nvidia/deepstream/deepstream-6.3/samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine
nvbufsurface: Could not get EGL display connection
nvbufsurface: Can't get EGL display
0:00:03.305406800 113117     0x28c87cc0 ERROR       nvinferallocator gstnvinfer_allocator.cpp:106:gst_nvinfer_allocator_alloc: Error: Could not map EglImage from NvBufSurface for nvinfer
0:00:03.305417649 113117     0x28c87cc0 WARN              GST_BUFFER gstbuffer.c:951:gst_buffer_new_allocate: failed to allocate 88 bytes
0:00:03.305431217 113117     0x28c87cc0 WARN              bufferpool gstbufferpool.c:305:do_alloc_buffer:<bufferpool0> alloc function failed
0:00:03.305438769 113117     0x28c87cc0 WARN              bufferpool gstbufferpool.c:338:default_start:<bufferpool0> failed to allocate buffer
0:00:03.305449905 113117     0x28c87cc0 ERROR             bufferpool gstbufferpool.c:559:gst_buffer_pool_set_active:<bufferpool0> start failed
0:00:03.305461297 113117     0x28c87cc0 WARN                 nvinfer gstnvinfer.cpp:994:gst_nvinfer_start:<primary-inference> error: Failed to set buffer pool to active
0:00:03.308267639 113117     0x28c87cc0 WARN                GST_PADS gstpad.c:1142:gst_pad_set_active:<primary-inference:sink> Failed to activate pad
Error: gst-resource-error-quark: Failed to set buffer pool to active (1): gstnvinfer.cpp(994): gst_nvinfer_start (): /GstPipeline:pipeline0/GstNvInfer:primary-inference

Seems like it fails on NvBufSurfaceMapEglImage in gstnvinfer_allocator.cpp; I’m not sure what the issue is.

Additionally, I’m not sure why there’s the Could not get EGL display connection error; the systemd target is currently set to multi-user.target and DISPLAY is unset. I’ve tried with export DISPLAY=:0 as well but got the same warning.

• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)

  1. Clone and build the deepstream bindings in GitHub - NVIDIA-AI-IOT/deepstream_python_apps: DeepStream SDK Python bindings and sample applications on the v1.1.8 tag
  2. patch in the following diff:
diff --git a/apps/deepstream-test1/deepstream_test_1.py b/apps/deepstream-test1/deepstream_test_1.py
index a03d326..8f99fca 100755
--- a/apps/deepstream-test1/deepstream_test_1.py
+++ b/apps/deepstream-test1/deepstream_test_1.py
@@ -172,23 +172,8 @@ def main(args):
     if not nvvidconv:
         sys.stderr.write(" Unable to create nvvidconv \n")
 
-    # Create OSD to draw on the converted RGBA buffer
-    nvosd = Gst.ElementFactory.make("nvdsosd", "onscreendisplay")
-
-    if not nvosd:
-        sys.stderr.write(" Unable to create nvosd \n")
-
     # Finally render the osd output
-    if is_aarch64():
-        print("Creating nv3dsink \n")
-        sink = Gst.ElementFactory.make("nv3dsink", "nv3d-sink")
-        if not sink:
-            sys.stderr.write(" Unable to create nv3dsink \n")
-    else:
-        print("Creating EGLSink \n")
-        sink = Gst.ElementFactory.make("nveglglessink", "nvvideo-renderer")
-        if not sink:
-            sys.stderr.write(" Unable to create egl sink \n")
+    sink = Gst.ElementFactory.make("fakesink", "nvvideo-renderer")
 
     print("Playing file %s " %args[1])
     source.set_property('location', args[1])
@@ -207,7 +192,6 @@ def main(args):
     pipeline.add(streammux)
     pipeline.add(pgie)
     pipeline.add(nvvidconv)
-    pipeline.add(nvosd)
     pipeline.add(sink)
 
     # we link the elements together
@@ -226,8 +210,7 @@ def main(args):
     srcpad.link(sinkpad)
     streammux.link(pgie)
     pgie.link(nvvidconv)
-    nvvidconv.link(nvosd)
-    nvosd.link(sink)
+    nvvidconv.link(sink)
 
     # create an event loop and feed gstreamer bus mesages to it
     loop = GLib.MainLoop()
@@ -235,22 +218,17 @@ def main(args):
     bus.add_signal_watch()
     bus.connect ("message", bus_call, loop)
 
-    # Lets add probe to get informed of the meta data generated, we add probe to
-    # the sink pad of the osd element, since by that time, the buffer would have
-    # had got all the metadata.
-    osdsinkpad = nvosd.get_static_pad("sink")
-    if not osdsinkpad:
-        sys.stderr.write(" Unable to get sink pad of nvosd \n")
-
-    osdsinkpad.add_probe(Gst.PadProbeType.BUFFER, osd_sink_pad_buffer_probe, 0)
-
     # start play back and listen to events
     print("Starting pipeline \n")
     pipeline.set_state(Gst.State.PLAYING)
+
     try:
         loop.run()
-    except:
-        pass
+    finally:
+        with open('/tmp/demo.dot', 'w') as outf:
+                        outf.write(Gst.debug_bin_to_dot_data(
+                                        pipeline, Gst.DebugGraphDetails.ALL
+                                                ))
     # cleanup
     pipeline.set_state(Gst.State.NULL)

run GST_DEBUG=3 python3 deepstream_test_1.py ../../../../samples/streams/sample_720p.h264

I am unsure if this helps at all but if you are using ssh,
trying using -X option.
ssh -X user@<IP>

If you are using ssh, I think it’s because you set the wrong DISPLAY value.

Try the command below to confirm the correct DISPLAY value

cat /proc/$(pidof "gnome-terminal-server")/environ | tr '\0' '\n' | grep ^DISPLAY=

Or try to unset using the following method

unset DISPLAY

I’ve tried unset DISPLAY and got the same result;

This is through a docker container on a BalenaOS yocto build with the BSP included.

I’m seeing the following in the stack trace:

ioctl(3, _IOC(_IOC_READ, 0x4e, 0x69, 0x28), 0xffffc799b330) = 0
ioctl(7, _IOC(_IOC_READ|_IOC_WRITE, 0x47, 0x1e, 0x10), 0xffffc799b250) = 0
openat(AT_FDCWD, "/sys/kernel/debug/clock/emc/possible_rates", O_RDONLY) = -1 ENOENT (No such file or directory)
ioctl(7, _IOC(_IOC_READ|_IOC_WRITE, 0x47, 0x1e, 0x10), 0xffffc799b250) = 0
openat(AT_FDCWD, "/sys/kernel/debug/clock/emc/possible_rates", O_RDONLY) = -1 ENOENT (No such file or directory)
getpid()                                = 113508
getpid()                                = 113508
futex(0xffff83deb7f0, FUTEX_WAKE_PRIVATE, 2147483647) = 0
ioctl(7, _IOC(_IOC_READ|_IOC_WRITE, 0x47, 0x1e, 0x10), 0xffffc799b400) = 0
openat(AT_FDCWD, "/sys/kernel/debug/clock/emc/possible_rates", O_RDONLY) = -1 ENOENT (No such file or directory)
ioctl(7, _IOC(_IOC_READ|_IOC_WRITE, 0x47, 0x1e, 0x10), 0xffffc799b400) = 0
openat(AT_FDCWD, "/sys/kernel/debug/clock/emc/possible_rates", O_RDONLY) = -1 ENOENT (No such file or directory)
ioctl(3, _IOC(_IOC_READ|_IOC_WRITE, 0x4e, 0, 0x8), 0xffffc799b750) = 0
ioctl(3, _IOC(_IOC_WRITE, 0x4e, 0x3, 0x10), 0xffffc799b740) = 0
ioctl(3, _IOC(_IOC_READ|_IOC_WRITE, 0x4e, 0xf, 0x8), 0xffffc799b760) = 0
getpid()                                = 113508
write(2, "0:00:04.435209279 \33[331m113508\33["..., 1910:00:04.435209279 113508     0x1eea10c0 WARN        nvinferallocator gstnvinfer_allocator.cpp:100:gst_nvinfer_allocator_alloc: [KEM] CREATED BUFFER, mapping
) = 191
getpid()                                = 113508
getpid()                                = 113508
write(1, "nvbufsurface: Could not get EGL "..., 50nvbufsurface: Could not get EGL display connection) = 50

re: openat(AT_FDCWD, "/sys/kernel/debug/clock/emc/possible_rates", O_RDONLY) = -1

are the DEBUGFS endpoints required for NvBufSurfaceMapEglImage or the EGL context?

What is this? Have you installed the corresponding version of JetPack? Are you running it inside docker? Can you share your command to start docker?

Is there any output from this command?

Yeah, we’ve added the jetpack sources.

The actual issue was the libEGL path, seems like mesa-egl overwrote the Jetpack version; LD_LIBRARY_PATH was missing the path to/usr/lib/aarch64-linux-gnu/tegra-egl; adding it to /etc/ld.so.conf.d/ fixed the issue.

Thanks!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.