Last active
April 1, 2024 12:05
-
-
Save m1k1o/28c73fc15cd1fba59b73364c3b7a5d0a to your computer and use it in GitHub Desktop.
Ubuntu Cuda Gstreamer Dockerfile (with nvcodec support)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ARG UBUNTU_RELEASE=20.04 | |
ARG CUDA_VERSION=11.4.2 | |
ARG GSTREAMER_VERSION=1.22 | |
# | |
# Stage 1 | |
# | |
FROM nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_RELEASE} AS gstreamer-builder | |
ARG GSTREAMER_VERSION | |
# | |
# install dependencies | |
ENV DEBIAN_FRONTEND=noninteractive | |
RUN set -eux; \ | |
apt-get update; \ | |
apt-get install -y --no-install-recommends \ | |
git ninja-build cmake pkg-config libmount-dev \ | |
flex bison bzip2 curl python3-pip; \ | |
pip3 install meson; \ | |
# minimize build by providing dev libraries | |
apt-get install -y --no-install-recommends zlib1g-dev libglib2.0-dev libffi-dev libssl-dev; \ | |
# plugins dependencies: soundtouch | |
apt-get install -y --no-install-recommends libsndfile1-dev libsoundtouch-dev libvpx-dev; \ | |
# plugin dependencies: pango | |
apt-get install -y --no-install-recommends libpango1.0-dev libpangocairo-1.0-0 libcairo2-dev; \ | |
# plugin dependencies: vaapi | |
apt-get install -y --no-install-recommends libva-dev; \ | |
# | |
# clean up | |
apt-get clean -y; \ | |
rm -rf /var/lib/apt/lists/* /var/cache/apt/* | |
# | |
# build gstreamer | |
RUN set -eux; \ | |
git clone https://gitlab.freedesktop.org/gstreamer/gstreamer.git /gstreamer/src --depth 1 --branch $GSTREAMER_VERSION; \ | |
cd /gstreamer/src; \ | |
meson --prefix=/gstreamer/install \ | |
-Dgpl=enabled \ | |
-Dvaapi=enabled \ | |
-Drs=disabled \ | |
-Dlibav=enabled \ | |
-Dgst-plugins-ugly:x264=enabled \ | |
-Dgst-plugins-base:pango=enabled \ | |
-Ddevtools=disabled \ | |
-Dtests=disabled \ | |
-Dexamples=disabled \ | |
-Ddoc=disabled \ | |
-Dorc=disabled \ | |
-Dlibsoup:sysprof=disabled \ | |
-Dbuildtype=release build; \ | |
ninja -C build; \ | |
meson install -C build; | |
# | |
# Stage 2 | |
# | |
FROM nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_RELEASE} AS final | |
# | |
# install dependencies | |
ENV DEBIAN_FRONTEND=noninteractive | |
RUN set -eux; \ | |
apt-get update; \ | |
apt-get install -y --no-install-recommends tzdata; \ | |
# dev versions may still be useful is image is used for dev purposes | |
apt-get install -y --no-install-recommends zlib1g-dev libglib2.0-dev libffi-dev libssl-dev; \ | |
# plugins dependencies: soundtouch, opencv, nvcodec, vaapi | |
apt-get install -y --no-install-recommends libsndfile1 libsoundtouch1 libopencv-dev libegl1 libgles-dev; \ | |
# dlib additionals | |
apt-get install -y --no-install-recommends libopenblas-base libopenblas-dev liblapack-dev libdlib-data; \ | |
# for plugin scanner | |
apt-get install -y --no-install-recommends libpython3.7; \ | |
# for CGO | |
apt-get install -y --no-install-recommends libunwind-dev libdw-dev; \ | |
# plugin dependencies: pango | |
# apt-get install -y --no-install-recommends libpango1.0-dev libpangocairo-1.0-0 libcairo2-dev; \ | |
# | |
# clean up | |
apt-get clean -y; \ | |
rm -rf /var/lib/apt/lists/* /var/cache/apt/* | |
COPY --from=gstreamer-builder /gstreamer/install /opt/gstreamer | |
# are all of them needed? | |
ENV PATH="${PATH}:/opt/gstreamer/bin" | |
ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/opt/gstreamer/lib/x86_64-linux-gnu" | |
ENV LIBRARY_PATH="${LIBRARY_PATH}:/opt/gstreamer/lib/x86_64-linux-gnu" | |
ENV PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/opt/gstreamer/lib/x86_64-linux-gnu/pkgconfig" | |
ENV CPLUS_INCLUDE_PATH="${CPLUS_INCLUDE_PATH}:/opt/gstreamer/include/gstreamer-1.0" | |
ENV GST_PLUGIN_PATH=/opt/gstreamer/lib/x86_64-linux-gnu/gstreamer-1.0 | |
ENV GST_PLUGIN_SCANNER=/opt/gstreamer/libexec/gstreamer-1.0/gst-plugin-scanner | |
ENV PYTHONPATH=opt/gstreamer/lib/python3.9/site-packages | |
ENV GI_TYPELIB_PATH=/opt/gstreamer/lib/x86_64-linux-gnu/girepository-1.0/ | |
ENV NVIDIA_DRIVER_CAPABILITIES all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment