stereolabs / zed-gstreamer

Package of GStreamer elements to interface with ZED Cameras
https://www.stereolabs.com/docs/gstreamer/
62 stars 24 forks source link

[BUG] CUDART issue when creating a Dockerfile for zed-gstreamer #25

Closed Dan-RT closed 2 years ago

Dan-RT commented 3 years ago

HI,

I'm trying to create a image based on stereolabs/zed:3.5-runtime-jetson-jp4.5 that would have zed-gstreamer in it. It is running on an Jetson Xavier NX.

However I'm getting this CUDART error very similar to the CUDA error described in the Readme file in the zed-docker repo (https://github.com/stereolabs/zed-docker/issues/34) : CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: CUDA_CUDART_LIBRARY (ADVANCED)

I'm already using the cmake custom parameters in the cmake command: cmake -DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs -DCMAKE_CXX_FLAGS="-Wl,--allow-shlib-undefined"

After some debugging I found out that cudart / libcudart.so is not in there: /usr/local/cuda/lib64/stubs

Thanks for your help!

Here is my Dockerfile:

# Specify the parent image from which we build
FROM stereolabs/zed:3.5-runtime-jetson-jp4.5

# Set the working directory
WORKDIR /app
EXPOSE 8554

RUN apt-get update && apt-get install -y apt-utils && apt-get install -y git
RUN apt-get install -y build-essential cmake libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav libgstrtspserver-1.0-0 gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstrtspserver-1.0-dev

# Clone and build zed-gstreamer project 
RUN git clone https://github.com/stereolabs/zed-gstreamer.git

WORKDIR /app/zed-gstreamer

RUN mkdir build 
RUN cmake -DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs -DCMAKE_CXX_FLAGS="-Wl,--allow-shlib-undefined" 
RUN make && make install
RUN gst-inspect-1.0 zedsrc && gst-inspect-1.0 zeddemux && gst-inspect-1.0 zeddatamux  && gst-inspect-1.0 zeddatacsvsink && gst-inspect-1.0 zedodoverlay

CMD ["gst-zed-rtsp-launch", "-p 8554 zedsrc stream-type=4 camera-resolution=1 ! videoconvert ! 'video/x-raw, format=(string)I420' ! x264enc ! rtph264pay pt=96 name=pay0"]
Myzhar commented 3 years ago

@Dan-RT can you try to add this flag to the CMake command? -DCUDA_CUDART_LIBRARY=/usr/local/cuda/lib64/libcudart.so

Dan-RT commented 3 years ago

Sure!

I tried this command then (adding also the release param): cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs -DCUDA_CUDART_LIBRARY=/usr/local/cuda/lib64/libcudart.so -DCMAKE_CXX_FLAGS="-Wl,--allow-shlib-undefined"

It goes a little bit further but still breaks: image

I added an ls on that path and the file is indeed missing: image

Thank you for your help!

Myzhar commented 3 years ago

We are investigating this problem. I will be back to you as soon as we find a solution.

adujardin commented 3 years ago

Hi @Dan-RT

I tried different things to get it to work, here's the Dockerfile I used at the end.

# Specify the parent image from which we build
FROM stereolabs/zed:3.5-runtime-jetson-jp4.5

# Set the working directory
WORKDIR /app
EXPOSE 8554

RUN apt-get update && apt-get install -y apt-utils && apt-get install -y git
RUN apt-get install -y build-essential cmake libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav libgstrtspserver-1.0-0 gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstrtspserver-1.0-dev

# Clone and build zed-gstreamer project 
RUN git clone https://github.com/adujardin/zed-gstreamer.git

WORKDIR /app/zed-gstreamer

RUN mkdir build 
RUN cmake -DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs -DCMAKE_CXX_FLAGS="-Wl,--allow-shlib-undefined" -DCUDA_CUDART_LIBRARY="/usr/local/cuda/lib64/libcudart.so"

RUN make && make install
#RUN gst-inspect-1.0 zedsrc && gst-inspect-1.0 zeddemux && gst-inspect-1.0 zeddatamux  && gst-inspect-1.0 zeddatacsvsink && gst-inspect-1.0 zedodoverlay

CMD ["gst-zed-rtsp-launch", "-p 8554 zedsrc stream-type=4 camera-resolution=1 ! videoconvert ! 'video/x-raw, format=(string)I420' ! x264enc ! rtph264pay pt=96 name=pay0"]

gst-inspect-1.0 can't be run at build time because the cuda libs are missing (they're mounting from the host on jetson at runtime)

It's building successfully the image, however, I didn't try to run it (I built it on my PC using qemu) and it's using a fork of zed-gstreamer I made. All changes may not be necessary but this is a preliminary step to solve this. We'll test further on our side to make the appropriate change in the main repo if needed.

Let us know if this is working for you

Dan-RT commented 3 years ago

Hi Aymeric!

I built it successfully too, however when I run the container it fails at identifying zedsrc element:

image

Zedsrc was the component that needed CUDART earlier.

The only difference with your Dockerfile is the CMD command format, I changed it for:

CMD gst-zed-rtsp-launch -p 8554 zedsrc stream-type=4 camera-resolution=1 ! videoconvert ! 'video/x-raw, format=(string)I420' ! x264enc ! rtph264pay pt=96 name=pay0

I hope this helps!