Deepstream CI direct download

I’m trying to build a Docker image from scratch that installs cuda, tensortr, and deepstream. Everything works in the following Dockerfile up until the point where I want to download and install DeepStream:

# an unofficial DeepStream Dockerfile
FROM ubuntu:bionic

ARG CPUS=8
ARG DEBIAN_FRONTEND=noninteractive

# install nvidia apt key and nvinfer repo.
RUN apt-get update && apt-get install -y --no-install-recommends \
    software-properties-common \
    ca-certificates \
    gnupg \
    wget \
    && wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin \
    && mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600 \
    && apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub \
    && add-apt-repository "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /" \
    && add-apt-repository "deb http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64 /" \
    && apt-get purge -y --autoremove wget gnupg software-properties-common \
    && rm -rf /var/lib/apt/lists/*

# install runtime depedencies for Deepstream
RUN apt-get update && apt-get install -y --no-install-recommends \
    # cuda \
    gstreamer1.0-libav \
    gstreamer1.0-plugins-bad \
    gstreamer1.0-plugins-good \
    gstreamer1.0-plugins-ugly \
    gstreamer1.0-tools \
    libgstreamer1.0-0 \
    libgstrtspserver-1.0-0 \
    libjansson4 \
    libnvinfer7 \
    libssl1.0.0 \
    && rm -rf /var/lib/apt/lists/*

# install librdkafka
RUN apt-get update && apt-get install -y --no-install-recommends \
    git \
    python \
    build-essential \
    && git clone https://github.com/edenhill/librdkafka.git \
    && cd librdkafka \
    && git reset --hard 7101c2310341ab3f4675fc565f64f0967e135a6a \
    && ./configure && make -j${CPUS} && make install \
    && cd .. \
    && rm -rf librdkafka \
    && mkdir -p /opt/nvidia/deepstream/deepstream-4.0/lib \
    && ln -rs /usr/local/lib/librdkafka* /opt/nvidia/deepstream/deepstream-4.0/lib \
    && apt-get purge -y --autoremove git python build-essential \
    && rm -rf /var/lib/apt/lists/*

# install DeepStream
RUN apt-get update && apt-get install -y --no-install-recommends \
    wget \
    && wget  --user-agent=Mozilla --content-disposition -E -c https://developer.nvidia.com/deepstream-402-t4-and-v100-deb \
    && dpkg -i deepstream-4.0_4.0.2-1_amd64.deb \
    && rm deepstream-4.0_4.0.2-1_amd64.deb \
    && apt-get purge -y --autoremove wget \
    && rm -rf /var/lib/apt/lists/*

image size: 1.21GB

All the layers build until the last RUN, at which point I am having trouble getting wget, or curl, to download DeepStream:

...
Setting up wget (1.19.4-1ubuntu2.2) ...
--2020-03-28 19:17:58--  https://developer.nvidia.com/deepstream-402-t4-and-v100-deb
Resolving developer.nvidia.com (developer.nvidia.com)... 152.199.0.24
Connecting to developer.nvidia.com (developer.nvidia.com)|152.199.0.24|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2020-03-28 19:17:58 ERROR 403: Forbidden.
...

Is there:

  • a direct download link for DeepStream. Right now it’s a redirect that neither wget nor curl can resolve.

(or)

Either one would suit my purposes. I could download the .deb manually, COPY it, and install it, but that’s adding a couple hundred megs to the size and i’m doing this in part in the hopes of trimming things down. I could also the .deb somewhere and pass that uri in as a build argument, but ideally I’d like to remove that requirement. Right now my docker images looks like this:

...
mdegans/nvalhalla           v0.1.2                542c1ede5a74        2 days ago          5.81GB
...
nvcr.io/nvidia/deepstream   4.0.2-19.12-devel     46df7d9545aa        3 months ago        5.67GB

While that’s not necessarily the size on disk, I’d still like to make a slim base image (I don’t need or want X11, for example).

Why not use the docker image we provide?

DeepStream on Jetson https://ngc.nvidia.com/catalog/containers/nvidia:deepstream-l4t
DeepStream on GPU https://ngc.nvidia.com/catalog/containers/nvidia:deepstream

Edit. Response to wrong post.

So, the reason I don’t want to use the official image is because:

  • It’s large (5.6Gb for all layers on x86). I believe I can slim that down a bit by not including some of the things eg. (x11), which are not needed by my app. My experiments indicate that all the x11 adds ~4-5Gb to the image. The DeepStream debian package still requires libx11-6, but this does not actually install x11 and only adds ~3Mb.
  • between Tegra and x86, things are not in the same place, the image name is not the same, and the tags are not the same. All current Tegra images bind mount stuff from the host and I wish to avoid that.

I am hoping to make an deepstream base image with identical tags and multi-arch support. That way my actual app’s Dockerfile can be identical for both x86 and Tegra. Otherwise I have to have different FROM lines and account for stuff like the headers being in different locations. For example, here is my app’s Dockerfile:

FROM nvcr.io/nvidia/deepstream:4.0.2-19.12-devel

# set up source dir and copy source
WORKDIR /opt/nvalhalla/source
COPY meson.build COPYING ./
COPY docs ./docs/
COPY includes ./includes/
COPY models ./models/
COPY nvinfer_configs ./nvinfer_configs/
COPY scripts ./scripts/
COPY src ./src

# install build and runtime dependencies, build, install, and uninstall build deps
RUN apt-get update && apt-get install -y --no-install-recommends \
    libgee-0.8-dev \
    libglib2.0-dev \
    libgstreamer1.0-dev \
    libgstrtspserver-1.0-dev \
    meson \
    valac \
    libgee-0.8-2 \
    && cp -R /root/deepstream_sdk_v4.0.2_x86_64/sources/ /opt/nvidia/deepstream/deepstream-4.0/ \
    && useradd -md /var/nvalhalla -rUs /bin/false nvalhalla \
    && mkdir build \
    && cd build \
    && meson .. \
    && ninja \
    && ninja install \
    && apt-get purge -y --autoremove \
    libgee-0.8-dev \
    libglib2.0-dev \
    libgstreamer1.0-dev \
    libgstrtspserver-1.0-dev \
    meson \
    valac

# drop caps and run nvalhalla using the rtsp sink
USER nvalhalla:nvalhalla
ENV G_MESSAGES_DEBUG="all"
EXPOSE 8554/tcp
ENTRYPOINT ["nvalhalla", "--sink", "rtsp"]

That has two issues. The base images are not the same on Tegra and x86, and the headers are in different locations in /root/deepstream_sdk_v4.0.2_$ARCH while they are in /opt/nvidia/deepstream/deepstream-4.0/sources/includes/ when installed from the .deb. I can account for this with my build system, but then I need to add logic to detect if I’m in docker.

Also, gcc and a bunch of -dev packages are already installed in the base image. I prefer to do that per-layer, removing any build stuff after i’m done building but before the layer is complete. Otherwise it unavoidably adds to the image size because layers are copy on write (at best) and I can’t get that used space back even if i purge the packages in my own layers.

tl;dr all I need to make things pretty is the .deb hosted someplace or in the online repos for both architectures.

Good requirements.

  1. Docker image is too large. Do not need x11, gcc
  2. Unify docker image, including source code position, build system, …
    Right?
1 Like

Yup, exactly. And the debian package with the same name in the repos. Right now it’s not in any x86 repo that I’m aware of.