From cuda import cudart ModuleNotFoundError: No module named 'cuda'

python3 deepstream_test_2.py /opt/nvidia/deepstream/deepstream-7.0/samples/streams/sample_720p.h264
Traceback (most recent call last):
File “/home/shalu/Documents/deepstream_python_apps/apps/deepstream-test2/deepstream_test_2.py”, line 28, in
from common.platform_info import PlatformInfo
File “/home/shalu/Documents/deepstream_python_apps/apps/deepstream-test2/…/common/platform_info.py”, line 21, in
from cuda import cudart
ModuleNotFoundError: No module named ‘cuda’.

my version of deepstream 7.0
NVIDIA-SMI 550.54.15 Driver Version: 550.54.15 CUDA Version: 12.4
nvcc --version :
nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Thu_Nov_18_09:45:30_PST_2021
Cuda compilation tools, release 11.5, V11.5.119
Build cuda_11.5.r11.5/compiler.30672275_0

how to solve issue.

Did you install the python bindings? Also deepstream_python_apps should be put in directory /opt/nvidia/deepstream/deepstream/sources/, please refer to the setup part here: GitHub - NVIDIA-AI-IOT/deepstream_python_apps: DeepStream SDK Python bindings and sample applications .

You need to install Deepstream Sdk first. If native sdk is not installed, python samples cannot run.

It is recommended to use docker

I already installed and showing opt folder deepstream.

path : /opt/nvidia/deepstream/deepstream-7.0

Install dependencies, then install python-cuda and pyds, refer to the README below.

pip3 install cuda-python

If you use docker, the following script will do all the steps for you

/opt/nvidia/deepstream/deepstream/user_deepstream_python_apps_install.sh --build-bindings -r master

Great. Thanks cuda issue fixed.
New error while testing test1:
python3 deepstream_test_1.py /opt/nvidia/deepstream/deepstream-7.0/samples/streams/sample_720p.h264
Creating Pipeline

Creating Source

Creating H264Parser

Unable to create h264 parser
Creating Decoder

Unable to create Nvv4l2 Decoder
Unable to create NvStreamMux
Unable to create pgie
Unable to create nvvidconv
Unable to create nvosd
Is it Integrated GPU? : 0
Creating EGLSink

Unable to create egl sink
Playing file /opt/nvidia/deepstream/deepstream-7.0/samples/streams/sample_720p.h264
Traceback (most recent call last):
File “/home/shalu/Documents/deepstream_python_apps/apps/deepstream-test1/deepstream_test_1.py”, line 263, in
sys.exit(main(sys.argv))
File “/home/shalu/Documents/deepstream_python_apps/apps/deepstream-test1/deepstream_test_1.py”, line 201, in main
streammux.set_property(‘width’, 1920)
AttributeError: ‘NoneType’ object has no attribute ‘set_property’

sudo /opt/nvidia/deepstream/deepstream/install.sh

If that doesn’t work, repeat the steps linked above.

sudo /opt/nvidia/deepstream/deepstream/install.sh
(myenv) (base) shalu@shalu-Nitro-AN515-57:~/Documents/deepstream_python_apps/apps/deepstream-test1$ python3 deepstream_test_1.py /opt/nvidia/deepstream/deepstream-7.0/samples/streams/sample_720p.h264
/snap/core20/current/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29’ not found (required by /lib/x86_64-linux-gnu/libproxy.so.1)
Failed to load module: /home/shalu/snap/code/common/.cache/gio-modules/libgiolibproxy.so
Creating Pipeline

Creating Source

Creating H264Parser

Unable to create h264 parser
Creating Decoder

Unable to create Nvv4l2 Decoder
Unable to create NvStreamMux
Unable to create pgie
Unable to create nvvidconv
Unable to create nvosd
Is it Integrated GPU? : 0
Creating EGLSink

Unable to create egl sink
Playing file /opt/nvidia/deepstream/deepstream-7.0/samples/streams/sample_720p.h264
Traceback (most recent call last):
File “/home/shalu/Documents/deepstream_python_apps/apps/deepstream-test1/deepstream_test_1.py”, line 263, in
sys.exit(main(sys.argv))
File “/home/shalu/Documents/deepstream_python_apps/apps/deepstream-test1/deepstream_test_1.py”, line 201, in main
streammux.set_property(‘width’, 1920)
AttributeError: ‘NoneType’ object has no attribute ‘set_property’

same error.

Please refer to the link I provided above

Based on binding references… I installed pyds using wheel.
now error:

python3 deepstream_test_1.py /home/shalu/Documents/deepstream_python_apps/apps/deepstream-test1/sample_720p.h264
Creating Pipeline

Creating Source

(python3:14008): GStreamer-WARNING **: 15:51:36.901: Failed to load plugin ‘/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstcoreelements.so’: /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstcoreelements.so: undefined symbol: gst_type_find_helper_for_data_with_extension

(python3:14008): GStreamer-CRITICAL **: 15:51:36.901: gst_element_factory_create_valist: assertion ‘newfactory != NULL’ failed
Unable to create Source
Creating H264Parser

(python3:14008): GStreamer-WARNING **: 15:51:36.902: Failed to load plugin ‘/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstvideoparsersbad.so’: /lib/x86_64-linux-gnu/libgstcodecparsers-1.0.so.0: undefined symbol: gst_bit_writer_init_with_size

(python3:14008): GStreamer-CRITICAL **: 15:51:36.902: gst_element_factory_create_valist: assertion ‘newfactory != NULL’ failed
Unable to create h264 parser
Creating Decoder

(python3:14008): GStreamer-WARNING **: 15:51:36.903: Failed to load plugin ‘/usr/lib/x86_64-linux-gnu/gstreamer-1.0/deepstream/libgstnvvideo4linux2.so’: /lib/x86_64-linux-gnu/libgstvideo-1.0.so.0: undefined symbol: gst_aggregator_simple_get_next_time

(python3:14008): GStreamer-CRITICAL **: 15:51:36.903: gst_element_factory_create_valist: assertion ‘newfactory != NULL’ failed
Unable to create Nvv4l2 Decoder

(python3:14008): GStreamer-WARNING **: 15:51:36.904: Failed to load plugin ‘/usr/lib/x86_64-linux-gnu/gstreamer-1.0/deepstream/libnvdsgst_multistream.so’: /lib/x86_64-linux-gnu/libgstaudio-1.0.so.0: undefined symbol: gst_aggregator_simple_get_next_time

(python3:14008): GStreamer-CRITICAL **: 15:51:36.904: gst_element_factory_create_valist: assertion ‘newfactory != NULL’ failed
Unable to create NvStreamMux

(python3:14008): GStreamer-WARNING **: 15:51:36.938: Failed to load plugin ‘/usr/lib/x86_64-linux-gnu/gstreamer-1.0/deepstream/libgstnvvideoconvert.so’: /lib/x86_64-linux-gnu/libgstvideo-1.0.so.0: undefined symbol: gst_aggregator_simple_get_next_time

(python3:14008): GStreamer-CRITICAL **: 15:51:36.938: gst_element_factory_create_valist: assertion ‘newfactory != NULL’ failed
Unable to create nvvidconv
Is it Integrated GPU? : 0
Creating EGLSink

(python3:14008): GStreamer-WARNING **: 15:51:36.950: Failed to load plugin ‘/usr/lib/x86_64-linux-gnu/gstreamer-1.0/deepstream/libnvdsgst_eglglessink.so’: /lib/x86_64-linux-gnu/libgstvideo-1.0.so.0: undefined symbol: gst_aggregator_simple_get_next_time

(python3:14008): GStreamer-CRITICAL **: 15:51:36.950: gst_element_factory_create_valist: assertion ‘newfactory != NULL’ failed
Unable to create egl sink
Playing file /home/shalu/Documents/deepstream_python_apps/apps/deepstream-test1/sample_720p.h264
Traceback (most recent call last):
File “/home/shalu/Documents/deepstream_python_apps/apps/deepstream-test1/deepstream_test_1.py”, line 264, in
sys.exit(main(sys.argv))
File “/home/shalu/Documents/deepstream_python_apps/apps/deepstream-test1/deepstream_test_1.py”, line 200, in main
source.set_property(‘location’, args[1])
AttributeError: ‘NoneType’ object has no attribute ‘set_property’

Please provide complete information as applicable to your setup.
• Hardware Platform (Jetson / GPU)
• DeepStream Version
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs)
• 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)
• The pipeline being used

https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_Installation.html#id1

Ubuntu 22.04
Deepstream version : 7.0
** NVIDIA-SMI 550.54.15 Driver Version: 550.54.15 CUDA Version: 12.4 **
**nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Thu_Nov_18_09:45:30_PST_2021
Cuda compilation tools, release 11.5, V11.5.119
Build cuda_11.5.r11.5/compiler.30672275_0
**

dpkg -l | grep gstreamer
ii gir1.2-gstreamer-1.0:amd64 1.20.3-0ubuntu1 amd64 GObject introspection data for the GStreamer library
ii gstreamer1.0-alsa:amd64 1.20.1-1ubuntu0.1 amd64 GStreamer plugin for ALSA
ii gstreamer1.0-clutter-3.0:amd64 3.0.27-2ubuntu1 amd64 Clutter PLugin for GStreamer 1.0
ii gstreamer1.0-gl:amd64 1.20.1-1ubuntu0.1 amd64 GStreamer plugins for GL
ii gstreamer1.0-gtk3:amd64 1.20.3-0ubuntu1.1 amd64 GStreamer plugin for GTK+3
ii gstreamer1.0-libav:amd64 1.20.3-0ubuntu1 amd64 ffmpeg plugin for GStreamer
ii gstreamer1.0-packagekit 1.2.5-2ubuntu2 amd64 GStreamer plugin to install codecs using PackageKit
ii gstreamer1.0-pipewire:amd64 0.3.48-1ubuntu3 amd64 GStreamer 1.0 plugin for the PipeWire multimedia server
ii gstreamer1.0-plugins-bad:amd64 1.20.3-0ubuntu1.1 amd64 GStreamer plugins from the “bad” set
ii gstreamer1.0-plugins-base:amd64 1.20.1-1ubuntu0.1 amd64 GStreamer plugins from the “base” set
ii gstreamer1.0-plugins-base-apps 1.20.1-1ubuntu0.1 amd64 GStreamer helper programs from the “base” set
ii gstreamer1.0-plugins-good:amd64 1.20.3-0ubuntu1.1 amd64 GStreamer plugins from the “good” set
ii gstreamer1.0-plugins-ugly:amd64 1.20.1-1 amd64 GStreamer plugins from the “ugly” set
ii gstreamer1.0-pulseaudio:amd64 1.20.3-0ubuntu1.1 amd64 GStreamer plugin for PulseAudio (transitional package)
ii gstreamer1.0-tools 1.20.3-0ubuntu1 amd64 Tools for use with GStreamer
ii gstreamer1.0-vaapi:amd64 1.20.1-1ubuntu1 amd64 VA-API plugins for GStreamer
ii gstreamer1.0-x:amd64 1.20.1-1ubuntu0.1 amd64 GStreamer plugins for X11 and Pango
ii libgstreamer-gl1.0-0:amd64 1.20.1-1ubuntu0.1 amd64 GStreamer GL libraries
ii libgstreamer-plugins-bad1.0-0:amd64 1.20.3-0ubuntu1.1 amd64 GStreamer libraries from the “bad” set
ii libgstreamer-plugins-base1.0-0:amd64 1.20.1-1ubuntu0.1 amd64 GStreamer libraries from the “base” set
ii libgstreamer-plugins-base1.0-dev:amd64 1.20.1-1ubuntu0.1 amd64 GStreamer development files for libraries from the “base” set
ii libgstreamer-plugins-good1.0-0:amd64 1.20.3-0ubuntu1.1 amd64 GStreamer development files for libraries from the “good” set
ii libgstreamer1.0-0:amd64 1.20.3-0ubuntu1 amd64 Core GStreamer libraries and elements
ii libgstreamer1.0-dev:amd64 1.20.3-0ubuntu1 amd64 GStreamer core development files

TensorRT: dpkg -l | grep nvinfer
ii libnvinfer-bin 10.0.1.6-1+cuda12.4 amd64 TensorRT binaries
ii libnvinfer-dev 8.6.1.6-1+cuda12.0 amd64 TensorRT development libraries
ii libnvinfer-dispatch-dev 8.6.1.6-1+cuda12.0 amd64 TensorRT development dispatch runtime libraries
ii libnvinfer-dispatch10 10.0.1.6-1+cuda12.4 amd64 TensorRT dispatch runtime library
ii libnvinfer-dispatch8 8.6.1.6-1+cuda12.0 amd64 TensorRT dispatch runtime library
ii libnvinfer-headers-dev 8.6.1.6-1+cuda12.0 amd64 TensorRT development headers
ii libnvinfer-headers-plugin-dev 8.6.1.6-1+cuda12.0 amd64 TensorRT plugin headers
ii libnvinfer-lean-dev 8.6.1.6-1+cuda12.0 amd64 TensorRT lean runtime libraries
ii libnvinfer-lean10 10.0.1.6-1+cuda12.4 amd64 TensorRT lean runtime library
ii libnvinfer-lean8 8.6.1.6-1+cuda12.0 amd64 TensorRT lean runtime library
ii libnvinfer-plugin-dev 8.6.1.6-1+cuda12.0 amd64 TensorRT plugin libraries
ii libnvinfer-plugin10 10.0.1.6-1+cuda12.4 amd64 TensorRT plugin libraries
ii libnvinfer-plugin8 8.6.1.6-1+cuda12.0 amd64 TensorRT plugin libraries
ii libnvinfer-samples 8.6.1.6-1+cuda12.0 all TensorRT samples
ii libnvinfer-vc-plugin-dev 8.6.1.6-1+cuda12.0 amd64 TensorRT vc-plugin library
ii libnvinfer-vc-plugin10 10.0.1.6-1+cuda12.4 amd64 TensorRT vc-plugin library
ii libnvinfer-vc-plugin8 8.6.1.6-1+cuda12.0 amd64 TensorRT vc-plugin library
ii libnvinfer10 10.0.1.6-1+cuda12.4 amd64 TensorRT runtime libraries
ii libnvinfer8 8.6.1.6-1+cuda12.0 amd64 TensorRT runtime libraries
ii python3-libnvinfer 10.0.1.6-1+cuda12.4 amd64 Python 3 bindings for TensorRT standard runtime
ii python3-libnvinfer-dispatch 10.0.1.6-1+cuda12.4 amd64 Python 3 bindings for TensorRT dispatch runtime
ii python3-libnvinfer-lean 10.0.1.6-1+cuda12.4 amd64 Python 3 bindings for TensorRT lean runtime

Does this shared library exist? /usr/lib/x86_64-linux-gnu/libgstbase-1.0.so.0

Looks like some deb packages are damaged.

apt-get update

apt-get install  --reinstall  -y gstreamer1.0-libav libgstreamer-plugins-base1.0-dev libgstreamer1.0-0 libgstrtspserver-1.0-0 

apt-get install --reinstall -y gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly  libswresample-dev libavutil-dev libavutil56 libavcodec-dev libavcodec58 libavformat-dev libavformat58 libavfilter7 libde265-dev libde265-0 libx265-199 libx264-163 libvpx7 libmpeg2encpp-2.1-0 libmpeg2-4 libmpg123-0

rm -rf ~/.cache/gstreamer-1.0/

apt install -y python3-gi python3-dev python3-gst-1.0 python-gi-dev git meson \
    python3 python3-pip python3.10-dev cmake g++ build-essential libglib2.0-dev \
    libglib2.0-dev-bin libgstreamer1.0-dev libtool m4 autoconf automake libgirepository1.0-dev libcairo2-dev


I installed as per you suggested.

/usr/lib/x86_64-linux-gnu/libgstbase-1.0.so.0 already in lib folder. I will share the screenshot of it.

python3 deepstream_test_1.py /home/shalu/Documents/deepstream_python_apps/apps/deepstream-test1/sample_720p.h264
libva info: VA-API version 1.14.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_14
libva info: va_openDriver() returns 0

(gst-plugin-scanner:9823): GStreamer-WARNING **: 14:54:48.747: Failed to load plugin ‘/usr/lib/x86_64-linux-gnu/gstreamer-1.0/deepstream/libnvdsgst_ucx.so’: libucs.so.0: cannot open shared object file: No such file or directory

(gst-plugin-scanner:9823): GStreamer-WARNING **: 14:54:48.774: Failed to load plugin ‘/usr/lib/x86_64-linux-gnu/gstreamer-1.0/deepstream/libnvdsgst_inferserver.so’: libtritonserver.so: cannot open shared object file: No such file or directory

(gst-plugin-scanner:9823): GStreamer-WARNING **: 14:54:49.003: Failed to load plugin ‘/usr/lib/x86_64-linux-gnu/gstreamer-1.0/deepstream/libnvdsgst_udp.so’: librivermax.so.1: cannot open shared object file: No such file or directory
GLib (gthread-posix.c): Unexpected error from C library during ‘pthread_setspecific’: Invalid argument. Aborting.
Creating Pipeline

Creating Source

(python3:9822): GStreamer-WARNING **: 14:55:06.453: Failed to load plugin ‘/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstcoreelements.so’: /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstcoreelements.so: undefined symbol: gst_type_find_helper_for_data_with_extension

(python3:9822): GStreamer-CRITICAL **: 14:55:06.453: gst_element_factory_create_valist: assertion ‘newfactory != NULL’ failed
Unable to create Source
Creating H264Parser

(python3:9822): GStreamer-WARNING **: 14:55:06.454: Failed to load plugin ‘/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstvideoparsersbad.so’: /lib/x86_64-linux-gnu/libgstcodecparsers-1.0.so.0: undefined symbol: gst_bit_writer_init_with_size

(python3:9822): GStreamer-CRITICAL **: 14:55:06.454: gst_element_factory_create_valist: assertion ‘newfactory != NULL’ failed
Unable to create h264 parser
Creating Decoder

(python3:9822): GStreamer-WARNING **: 14:55:06.455: Failed to load plugin ‘/usr/lib/x86_64-linux-gnu/gstreamer-1.0/deepstream/libgstnvvideo4linux2.so’: /lib/x86_64-linux-gnu/libgstvideo-1.0.so.0: undefined symbol: gst_aggregator_simple_get_next_time

(python3:9822): GStreamer-CRITICAL **: 14:55:06.455: gst_element_factory_create_valist: assertion ‘newfactory != NULL’ failed
Unable to create Nvv4l2 Decoder

(python3:9822): GStreamer-WARNING **: 14:55:06.456: Failed to load plugin ‘/usr/lib/x86_64-linux-gnu/gstreamer-1.0/deepstream/libnvdsgst_multistream.so’: /lib/x86_64-linux-gnu/libgstaudio-1.0.so.0: undefined symbol: gst_aggregator_simple_get_next_time

(python3:9822): GStreamer-CRITICAL **: 14:55:06.456: gst_element_factory_create_valist: assertion ‘newfactory != NULL’ failed
Unable to create NvStreamMux

(python3:9822): GStreamer-WARNING **: 14:55:06.488: Failed to load plugin ‘/usr/lib/x86_64-linux-gnu/gstreamer-1.0/deepstream/libgstnvvideoconvert.so’: /lib/x86_64-linux-gnu/libgstvideo-1.0.so.0: undefined symbol: gst_aggregator_simple_get_next_time

(python3:9822): GStreamer-CRITICAL **: 14:55:06.488: gst_element_factory_create_valist: assertion ‘newfactory != NULL’ failed
Unable to create nvvidconv
Is it Integrated GPU? : 0
Creating EGLSink

(python3:9822): GStreamer-WARNING **: 14:55:06.504: Failed to load plugin ‘/usr/lib/x86_64-linux-gnu/gstreamer-1.0/deepstream/libnvdsgst_eglglessink.so’: /lib/x86_64-linux-gnu/libgstvideo-1.0.so.0: undefined symbol: gst_aggregator_simple_get_next_time

(python3:9822): GStreamer-CRITICAL **: 14:55:06.504: gst_element_factory_create_valist: assertion ‘newfactory != NULL’ failed
Unable to create egl sink
Playing file /home/shalu/Documents/deepstream_python_apps/apps/deepstream-test1/sample_720p.h264
Traceback (most recent call last):
File “/home/shalu/Documents/deepstream_python_apps/apps/deepstream-test1/deepstream_test_1.py”, line 264, in
sys.exit(main(sys.argv))
File “/home/shalu/Documents/deepstream_python_apps/apps/deepstream-test1/deepstream_test_1.py”, line 200, in main
source.set_property(‘location’, args[1])
AttributeError: ‘NoneType’ object has no attribute ‘set_property’

It looks like your OS has some weird issues.

Notice that your GPU driver version is 550 and your cuda version is 11.5, which does not match DS-7.0. Please refer to the link below to install a compatible version

https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_Installation.html#id9

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

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