basler / gst-plugin-pylon

The official GStreamer plug-in for Basler cameras
BSD 3-Clause "New" or "Revised" License
40 stars 10 forks source link

Unable to build 7.4.0 with NVMM support on Linux / Jetson Orin #82

Closed goncalog closed 8 months ago

goncalog commented 8 months ago

Describe the bug While following the Linux build steps from the README I'm unable to compile the pylonsrc element with NVMM support enabled:

Library nvbufsurface found: YES
Run-time dependency CUDA (modules: cudart_static, rt, pthread, dl) found: NO (tried system)
Message: Deepstream or CUDA not found, skipping NVMM support

This happens despite running the steps inside a container with (DeepStream and) CUDA. The container I'm running is based on the nvcr.io/nvidia/deepstream-l4t:6.2-base docker image which installs both of those dependencies. And LD_LIBRARY_PATH is pointing correctly to /workspace/lib:/usr/local/cuda-11.4/lib64.

Should the modules cudart_static, rt, pthread, dl be found in /usr/local/cuda-11.4/lib64? They aren't in my case.

Expected behavior Build with NVMM support enabled.

Environment

goncalog commented 8 months ago

Yes, looking at the meson code (see below) it seems it expects those modules to be found in /usr/local/cuda-11.4/lib64:

from cuda.py

       if not any(runtime in self.requested_modules for runtime in ['cudart', 'cudart_static']):
            # By default, we prefer to link the static CUDA runtime, since this is what nvcc also does by default:
            # https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#cudart-none-shared-static-cudart
            req_modules = ['cudart']
            if kwargs.get('static', True):
                req_modules = ['cudart_static']
                machine = self.env.machines[self.for_machine]
                if machine.is_linux():
                    # extracted by running
                    #   nvcc -v foo.o
                    req_modules += ['rt', 'pthread', 'dl']
            self.requested_modules = req_modules + self.requested_modules

And your build expects cuda_runtime.h to be there too. Otherwise one gets the error: ./ext/pylon/gstpylon.cpp:38:12: fatal error: cuda_runtime.h: No such file or directory.

I suspect this means we need to install the full CUDA Toolkit rather than relying on the libs that come with Nvidia's DS docker image (i.e. nvcr.io/nvidia/deepstream-l4t:6.2-base). Is this correct @thiesmoeller, or is there an alternative? Thank you!

thiesmoeller commented 8 months ago

How do you start the container? Please give the full commandline.

Overall you need the deepstream and cuda-rt development packages.

apt-get update
apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev cmake cuda-cudart-dev-11-4 deepstream-6.2
# download pylon debian installers
tar -xvf pylon_7_4_0_14900_linux_aarch64_debs.tar.gz 
apt-get install ./*.deb
# install python tools
pip3 install meson ninja
#
git clone https://github.com/basler/gst-plugin-pylon.git
cd gst-plugin-pylon/
PYLON_ROOT=/opt/pylon/ meson setup build

It might still fail to build because the relevant file in /opt/nvidia/deepstream/deepstream/lib is only a sym-link to the real libs that are missing ( depending on your docker call )

 libnvbufsurface.so -> /usr/lib/aarch64-linux-gnu/tegra/libnvbufsurface.so
 libnvbufsurftransform.so -> /usr/lib/aarch64-linux-gnu/tegra/libnvbufsurftransform.so

the nvidia runtime ( add --runtime nvidia ) should dynamically link the correct libs from the base system in the container ( https://forums.developer.nvidia.com/t/how-to-enable-cuda-in-jetson-orin-nx-16gb-module-using-docker/270314/3 )

goncalog commented 8 months ago

hi @thiesmoeller, we managed to compile it by using a different docker image (ds6.2 triton) and adding the missing libs you mention. thank you

kostastsing commented 3 months ago

Hi @goncalog. I am experiencing the same problem when trying to install the plugin in deepstream-l4t:6.4-triton-multiarch docker image. I have changed the code in meson.build to search in /usr/lib/aarch64-linux-gnu/tegra/ for finding libnvbufsurface.so but I am always getting that Library nvbufsurface found: NO. How did you manage to resolve the problem?

UPDATE: I have managed to build the plugin inside the aforementioned container but I am getting errors when using the plugin as I mention here