Problem with the library path

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU)
all of the above
• DeepStream Version
5.0
• JetPack Version (valid for Jetson only)
4.4
• TensorRT Version
7.1 i think
• NVIDIA GPU Driver Version (valid for GPU only)
440.64.00

Hey, so I’m making a plugin package for deepstream with an element to work with nvosd to do social distancing. Everything compiles - no errors or warning, but the darned plugin won’t find the shared libraries needed at runtime since they’re not in LD_LIBRARY_PATH.

[mdegans@konjin] -- [~/Projects/gst-cuda-plugin/build] 
 $ gst-inspect-1.0 /usr/local/lib/x86_64-linux-gnu/gstreamer-1.0/libgstcudaplugin.so 

(gst-inspect-1.0:820): GStreamer-WARNING **: 22:35:00.748: Failed to load plugin '/usr/local/lib/x86_64-linux-gnu/gstreamer-1.0/libgstcudaplugin.so': libnvdsgst_meta.so: cannot open shared object file: No such file or directory
Could not load plugin file: Opening module failed: libnvdsgst_meta.so: cannot open shared object file: No such file or directory
[mdegans@konjin] -- [~/Projects/gst-cuda-plugin/build] 
 $ LD_LIBRARY_PATH=/opt/nvidia/deepstream/deepstream/lib/ gst-inspect-1.0 /usr/local/lib/x86_64-linux-gnu/gstreamer-1.0/libgstcudaplugin.so 
Plugin Details:
  Name                     cudaplugin
  Description              CUDA Plugin collection for GStreamer and DeepStream.
  Filename                 /usr/local/lib/x86_64-linux-gnu/gstreamer-1.0/libgstcudaplugin.so
  Version                  0.1
  License                  LGPL
  Source module            gstcudaplugin
  Binary package           gstcudaplugin-1.0
  Origin URL               https://github.com/mdegans/gst-cuda-plugin

  cudafilter: CUDA Filter element
  cudahash: CUDA Image hashing element
  dsdistance: DeepStream social distancing element

  3 features:
  +-- 3 elements

My C/C++ is pretty basic but my understanding is that this is becuase i’m making a shared library and it can’t find the linked one at runtime.

I tried adding this manually by adding it to a linker flags option:

-Xlinker=-rpath=/opt/nvidia/deepstream/deepstream-5.0/lib

but my build system is adding a second -rpath that breaks this. I get /bin/sh: 1: nvcc: not found when I try as a result.

Are there any suggested solutions. I tried a static library option and i get not found by nvcc as well. Could this be related to the non-standard paths DeepStream uses?

Googling around a bit the attitude I find on threads where this happens is that if, say, libfoo.so can’t be found, libfoo isn’t packaged properly to begin with. It’s unhelpful, so I’m hoping I can find a solution here.

also, static linking is out since it, too, will fail with not found. Any help would be much appreciated.

Edit: oddly, this worked in DS 4.0 since I have tests that ran before but now fail like:

--- command ---
23:59:36 GST_DEBUG='5' GST_PLUGIN_PATH='/home/mdegans/Projects/gst-cuda-plugin/build/gst-cuda-plugin/test/../' GST_REGISTRY_UPDATE='yes' /home/mdegans/Projects/gst-cuda-plugin/build/meson-out/test_gstcudahash
--- stderr ---
/home/mdegans/Projects/gst-cuda-plugin/build/meson-out/test_gstcudahash: error while loading shared libraries: libnvdsgst_meta.so: cannot open shared object file: No such file or directory
-------
...

Also have a test Dockerfile that won’t build but did before (it runs the tests at the build stage). Same cause.

Hi,
Please refer to

/opt/nvidia/deepstream/deepstream-5.0/install.sh

You probably need to add the path and execute sudo ldconfig.

Or you may clean the cache for a try:

$ rm ${HOME}/.cache/gstreamer-1.0/registry.aarch64.bin
1 Like
 $ rm ~/.cache/gstreamer-1.0/registry.x86_64.bin
[mdegans@konjin] -- [~/Projects/gst-cuda-plugin] 
 $ gst-inspect-1.0 foo

(gst-plugin-scanner:21405): GStreamer-WARNING **: 03:15:12.895: Failed to load plugin '/usr/lib/x86_64-linux-gnu/gstreamer-1.0/deepstream/libnvdsgst_inferserver.so': libtrtserver.so: cannot open shared object file: No such file or directory
No such element or plugin 'foo'

Problem is here:

[username@hostname] -- [/etc/ld.so.conf.d] 
 $ cat deepstream.conf 
/opt/nvidia/deepstream/deepstream-4.0/lib

In the deepstream 5.0 image the .conf doesn’t exist at all:

 $ docker run -it --rm nvcr.io/nvidia/deepstream:5.0-dp-20.04-base
root@536ac11cc55e:/# cat /etc/ld.so.conf.d/ (hit tab a few times here)
cuda-10-2.conf         i386-linux-gnu.conf    libc.conf              nvidia.conf            x86_64-linux-gnu.conf  
root@536ac11cc55e:/# cat /etc/ld.so.conf.d/nvidia.conf 
/usr/local/nvidia/lib
/usr/local/nvidia/lib64
/usr/local/nvidia/lib
/usr/local/nvidia/lib64
root@536ac11cc55e:/# 

But it does on ds4.0:

 $ docker run -it --rm nvcr.io/nvidia/deepstream:4.0.2-19.12-devel
root@786fd379c306:/# ls /etc/ld.so.conf.d/
cuda-10-1.conf  deepstream.conf  i386-linux-gnu.conf  libc.conf  nvidia.conf  x86_64-linux-gnu.conf
root@786fd379c306:/# cat /etc/ld.so.conf.d/deepstream.conf 
/opt/nvidia/deepstream/deepstream-4.0/lib

Thanks for helping me track down the problem @DaneLLL

I’ll modify the .conf and i’m pretty sure that’ll fix it.

Et voila! Merci!

 $ gst-inspect-1.0 build/meson-out/libgstcudaplugin.so 
Plugin Details:
  Name                     cudaplugin
  Description              CUDA Plugin collection for GStreamer and DeepStream.
  Filename                 build/meson-out/libgstcudaplugin.so
  Version                  0.1
  License                  LGPL
  Source module            gstcudaplugin
  Binary package           gstcudaplugin-1.0
  Origin URL               https://github.com/mdegans/gst-cuda-plugin

  cudafilter: CUDA Filter element
  cudahash: CUDA Image hashing element
  dsdistance: DeepStream social distancing element

  3 features:
  +-- 3 elements