NVIDIA-AI-IOT / deepstream_dockers

A project demonstrating how to make DeepStream docker images.
MIT License
60 stars 11 forks source link

on Jetson, no lnvbufsurface #11

Open jahwanoh opened 7 months ago

jahwanoh commented 7 months ago

jetpack 5.1.2

base: nvcr.io/nvidia/deepstream:6.4-triton-multiarch

I want to build a custom plugin, however it cannot find nvidia multimedia library. how can I fix this?

/opt/nvidia/deepstream/deepstream-6.4/sources/gst-plugins/gst-dsexample# CUDA_VER=12 make -j8
make -C dsexample_lib/
-fPIC -DDS_VERSION="6.4.0" -I /usr/local/cuda-12/include -I ../../includes -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/orc-0.4 -I/usr/include/gstreamer-1.0 -I/usr/include/aarch64-linux-gnu -I/usr/include/glib-2.0 -I/usr/lib/aarch64-linux-gnu/glib-2.0/include
g++ -c -o gstdsexample.o -fPIC -DDS_VERSION=\"6.4.0\" -I /usr/local/cuda-12/include -I ../../includes -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/orc-0.4 -I/usr/include/gstreamer-1.0 -I/usr/include/aarch64-linux-gnu -I/usr/include/glib-2.0 -I/usr/lib/aarch64-linux-gnu/glib-2.0/include gstdsexample.cpp
make[1]: Entering directory '/opt/nvidia/deepstream/deepstream-6.4/sources/gst-plugins/gst-dsexample/dsexample_lib'
gcc -ggdb -c -o dsexample_lib.o -fPIC dsexample_lib.c
ar rcs libdsexample.a dsexample_lib.o
make[1]: Leaving directory '/opt/nvidia/deepstream/deepstream-6.4/sources/gst-plugins/gst-dsexample/dsexample_lib'
-fPIC -DDS_VERSION="6.4.0" -I /usr/local/cuda-12/include -I ../../includes -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/orc-0.4 -I/usr/include/gstreamer-1.0 -I/usr/include/aarch64-linux-gnu -I/usr/include/glib-2.0 -I/usr/lib/aarch64-linux-gnu/glib-2.0/include
g++ -o libnvdsgst_dsexample.so gstdsexample.o -shared -Wl,-no-undefined -L dsexample_lib -ldsexample -L/usr/local/cuda-12/lib64/ -lcudart -ldl -lnppc -lnppig -lnpps -lnppicc -lnppidei -L/opt/nvidia/deepstream/deepstream-6.4/lib/ -lnvdsgst_helper -lnvdsgst_meta -lnvds_meta -lnvbufsurface -lnvbufsurftransform -Wl,-rpath,/opt/nvidia/deepstream/deepstream-6.4/lib/ -lgstvideo-1.0 -lgstbase-1.0 -lgstreamer-1.0 -lgobject-2.0 -lglib-2.0
/usr/bin/ld: cannot find -lnvbufsurface: No such file or directory
/usr/bin/ld: cannot find -lnvbufsurftransform: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:85: libnvdsgst_dsexample.so] Error 1
whittenator commented 1 week ago

@jahwanoh I ran into the same exact issue, the only way I could figure this out was to copy libnvbufsurface/lnvbufsurftransform and their dependencies from my Jetson device and create symlinks in my Dockerfile. It's not the cleanest but it allowed my to build gst-dsexample which requires these two libraries. Here the portion of my Dockerfile that I used to get this running:

FYI I literally copied the entire tegra folder from my Jetson to by build area from the Jetson device /usr/lib/aarch64-linux-gnu/tegra/.

#Copy all required library files to both directories
COPY tegra/libnvbufsurface.so.1.0.0 /usr/lib/aarch64-linux-gnu/nvidia/
COPY tegra/libnvbufsurftransform.so.1.0.0 /usr/lib/aarch64-linux-gnu/nvidia/
COPY tegra/libnvrm_mem.so* /usr/lib/aarch64-linux-gnu/nvidia/
COPY tegra/libnvrm_surface.so* /usr/lib/aarch64-linux-gnu/nvidia/
COPY tegra/libnvrm_chip.so* /usr/lib/aarch64-linux-gnu/nvidia/
COPY tegra/libnvos.so* /usr/lib/aarch64-linux-gnu/nvidia/
COPY tegra/libnvbuf_fdmap.so.1.0.0 /usr/lib/aarch64-linux-gnu/nvidia/
COPY tegra/libnvrm_gpu.so* /usr/lib/aarch64-linux-gnu/nvidia/
COPY tegra/libnvrm_host1x.so* /usr/lib/aarch64-linux-gnu/nvidia/
COPY tegra/libnvvic.so* /usr/lib/aarch64-linux-gnu/nvidia/
COPY tegra/libnvdla_compiler.so* /usr/lib/aarch64-linux-gnu/nvidia/
COPY tegra/libnvcudla.so* /usr/lib/aarch64-linux-gnu/nvidia/
# Additional dependencies
COPY tegra/libnvsciipc.so* /usr/lib/aarch64-linux-gnu/nvidia/
COPY tegra/libnvsocsys.so* /usr/lib/aarch64-linux-gnu/nvidia/
COPY tegra/libnvrm_sync.so* /usr/lib/aarch64-linux-gnu/nvidia/
COPY tegra/libnvtegrahv.so* /usr/lib/aarch64-linux-gnu/nvidia/
COPY tegra/libnvrm_stream.so* /usr/lib/aarch64-linux-gnu/nvidia/
COPY tegra/libnvcolorutil.so* /usr/lib/aarch64-linux-gnu/nvidia/
COPY tegra/libcuda.so* /usr/lib/aarch64-linux-gnu/nvidia/
COPY tegra/libnvdla_runtime.so* /usr/lib/aarch64-linux-gnu/nvidia/

# Copy the same files to tegra directory
COPY tegra/libnvbufsurface.so.1.0.0 /usr/lib/aarch64-linux-gnu/tegra/
COPY tegra/libnvbufsurftransform.so.1.0.0 /usr/lib/aarch64-linux-gnu/tegra/
COPY tegra/libnvrm_mem.so* /usr/lib/aarch64-linux-gnu/tegra/
COPY tegra/libnvrm_surface.so* /usr/lib/aarch64-linux-gnu/tegra/
COPY tegra/libnvrm_chip.so* /usr/lib/aarch64-linux-gnu/tegra/
COPY tegra/libnvos.so* /usr/lib/aarch64-linux-gnu/tegra/
COPY tegra/libnvbuf_fdmap.so.1.0.0 /usr/lib/aarch64-linux-gnu/tegra/
COPY tegra/libnvrm_gpu.so* /usr/lib/aarch64-linux-gnu/tegra/
COPY tegra/libnvrm_host1x.so* /usr/lib/aarch64-linux-gnu/tegra/
COPY tegra/libnvvic.so* /usr/lib/aarch64-linux-gnu/tegra/
COPY tegra/libnvdla_compiler.so* /usr/lib/aarch64-linux-gnu/tegra/
COPY tegra/libnvcudla.so* /usr/lib/aarch64-linux-gnu/tegra/
# Additional dependencies in tegra
COPY tegra/libnvsciipc.so* /usr/lib/aarch64-linux-gnu/tegra/
COPY tegra/libnvsocsys.so* /usr/lib/aarch64-linux-gnu/tegra/
COPY tegra/libnvrm_sync.so* /usr/lib/aarch64-linux-gnu/tegra/
COPY tegra/libnvtegrahv.so* /usr/lib/aarch64-linux-gnu/tegra/
COPY tegra/libnvrm_stream.so* /usr/lib/aarch64-linux-gnu/tegra/
COPY tegra/libnvcolorutil.so* /usr/lib/aarch64-linux-gnu/tegra/
COPY tegra/libcuda.so* /usr/lib/aarch64-linux-gnu/tegra/
COPY tegra/libnvdla_runtime.so* /usr/lib/aarch64-linux-gnu/tegra/

# Create symbolic links for all libraries in nvidia directory
RUN cd /usr/lib/aarch64-linux-gnu/nvidia && \
    for f in *.so.*; do \
    base=$(echo $f | sed 's/\([^.]*\).so.*/\1.so/'); \
    ln -sf $f $base; \
    done

# Create symbolic links for all libraries in tegra directory
RUN cd /usr/lib/aarch64-linux-gnu/tegra && \
    for f in *.so.*; do \
    base=$(echo $f | sed 's/\([^.]*\).so.*/\1.so/'); \
    ln -sf $f $base; \
    done

RUN ldconfig

It's a messy fix, I would hope that one of the maintainers of this repository has a better fix!