Addin import cv2 or numpy in deepstream_test_3.py and running rtsp stream causes seg-fault

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) GPU (A100)
• DeepStream Version 7.0
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only) 535.161.08
• Issue Type( questions, new requirements, bugs) bug
• 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)
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)

Hi,

I’m running in a deepstream docker environment based on nvcr.io/nvidia/deepstream:7.0-samples-multiarch, in a A100 dgx platform, when I use the original test using file input or rtsp input everything works as expected, but if use rtsp and I import either cv2 or numpy in deepstream_test_3.py even if I don’t use them I get a seg fault crash (with a file input it doesn’t happen even if I use cv2 and numpy), here is the backtrace from gdb:

(gdb) bt
#0 0x00007ffff5607550 in () at /lib/x86_64-linux-gnu/libstdc++.so.6
#1 0x00007ffff5607a94 in __gxx_personality_v0 () at /lib/x86_64-linux-gnu/libstdc++.so.6
#2 0x00007ffff40adfe9 in __libunwind_Unwind_Resume () at /lib/x86_64-linux-gnu/libunwind.so.8
#3 0x00007fffae1e386d in () at /lib/x86_64-linux-gnu/libproxy.so.1
#4 0x00007fffae1ec827 in px_proxy_factory_get_proxies () at /lib/x86_64-linux-gnu/libproxy.so.1
#5 0x00007fffd7b49827 in () at /usr/lib/x86_64-linux-gnu/gio/modules/libgiolibproxy.so
#6 0x00007ffff44ea644 in g_task_thread_pool_thread (thread_data=0x7fff74012140, pool_data=) at …/gio/gtask.c:1531
#7 0x00007ffff4742384 in g_thread_pool_thread_proxy (data=) at …/glib/gthreadpool.c:350
#8 0x00007ffff4741ac1 in g_thread_proxy (data=0x7fff68002000) at …/glib/gthread.c:831
#9 0x00007ffff7cdfac3 in start_thread (arg=) at ./nptl/pthread_create.c:442
#10 0x00007ffff7d71850 in clone3 () at …/sysdeps/unix/sysv/linux/x86_64/clone3.S:81

the opencv version is
opencv-python 4.10.0.84
the numpy version is:
numpy 2.1.0

thanks

Try upgrading pygobject. I’m not sure if it’s a pyds problem. Are you just import cv2/import numpy as ny?

python3 -m pip install --upgrade pygobject

yes, just import cv2 or import numpy as np
I’ve upgraded PyGObject to latest version:
PyGObject 3.48.2
it didn’t solve the problem, the crash still happens

btw this is the output of the crash:

0:01:02.343013645 362777 0x55d5c63cd910 INFO nvinfer gstnvinfer.cpp:682:gst_nvinfer_logger: NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::buildModel() <nvdsinfer_context_impl.cpp:2141> [UID = 1]: serialize cuda engine to file: /opt/nvidia/deepstream/deepstream-7.0/samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b1_gpu0_int8.engine successfully
INFO: …/nvdsinfer/nvdsinfer_model_builder.cpp:612 [Implicit Engine Info]: layers num: 3
0 INPUT kFLOAT input_1 3x544x960
1 OUTPUT kFLOAT output_bbox/BiasAdd 16x34x60
2 OUTPUT kFLOAT output_cov/Sigmoid 4x34x60

0:01:02.739848838 362777 0x55d5c63cd910 INFO nvinfer gstnvinfer_impl.cpp:343:notifyLoadModelStatus: [UID 1]: Load new model:dstest3_pgie_config.txt sucessfully
Decodebin child added: source

**PERF: {‘stream0’: 0.0}

Aborted (core dumped)

1 Like

Can you please run

It uses cv2 and numpy
Thanks

How do you install the numpy or opencv ?

If you just run the following command line, will it crash?

python3  -c "import sys, numpy; print(numpy.version)"

Can this sample run correctly?

deepstream-imagedata-multistream works,
after comparing the difference between the test I used (deepstream_test_3.py) and deepstream-imagedata-multistream, I tried to move the import numpy to the location of the test that works, I found that the position of the import is important, if the import numpy is before the line
“from gi.repository import GLib, Gst”
I get a crash, but if the import numpy is after that line, there is no crash.

this is the output:

<module ‘numpy.version’ from ‘/usr/local/lib/python3.10/dist-packages/numpy/version.py’>

see my previous answer regarding the deepstream-imagedata-multistream

Can you share the Dockerfile?

I can’t reproduce the crash whether I import numpy before or after from gi.repository import GLib, Gst

If you use deepstream:7.0-triton-multiarch directly, can you reproduce the crash?

There is no update from you for a period, assuming this is not an issue anymore. Hence we are closing this topic. If need further support, please open a new one. Thanks