From feb8ffef1be8ec66243ea600d3a4f6213d9034ef Mon Sep 17 00:00:00 2001 From: Angel Iglesias Date: Sun, 5 May 2024 16:29:01 +0200 Subject: [PATCH] Upgrade base image to 24.04 and Cuda 12.2 Signed-off-by: Angel Iglesias --- .github/workflows/build.yml | 2 +- Dockerfile | 17 ++++++++++++--- Dockerfile.cuda | 42 +++++++++++++++++++++++++++++++------ Dockerfile.dev | 14 ++++++------- Makefile | 26 ++++++++++++----------- extra-packages | 2 +- 6 files changed, 73 insertions(+), 30 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1c2be34..533f3f2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: uses: redhat-actions/buildah-build@v2 with: image: ubuntu-toolbox - tags: latest 22.04 + tags: latest 24.04 containerfiles: | ./Dockerfile diff --git a/Dockerfile b/Dockerfile index 437a813..1d188d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG RELEASE=22.04 +ARG RELEASE=24.04 FROM docker.io/library/ubuntu:${RELEASE} @@ -8,7 +8,7 @@ LABEL com.github.containers.toolbox="true" \ version="${RELEASE}" \ usage="This image is meant to be used with the toolbox command" \ summary="Base image for creating Ubuntu toolbox containers" \ - maintainer="Debarshi Ray " + maintainer="Angel Iglesias " COPY README.md / @@ -25,7 +25,8 @@ RUN sed -Ei '/apt-get (update|upgrade)/s/^/#/' /usr/local/sbin/unminimize && \ yes | /usr/local/sbin/unminimize && \ DEBIAN_FRONTEND=noninteractive apt-get -y install \ ubuntu-minimal ubuntu-standard \ - libnss-myhostname && \ + libnss-myhostname \ + flatpak-xdg-utils && \ DEBIAN_FRONTEND=noninteractive apt-get -y install \ --no-install-recommends \ gnome-terminal && \ @@ -44,4 +45,14 @@ RUN sed -i '/^auth.*pam_unix.so/s/nullok_secure/try_first_pass nullok/' /etc/pam # Fix empty bind-mount to clear selinuxfs (see #337) RUN mkdir /usr/share/empty +# Add flatpak-spawn to /usr/bin +RUN ln -s /usr/libexec/flatpak-xdg-utils/flatpak-spawn /usr/bin/ + +# Having anything in /home prevents toolbox from symlinking /var/home there, +# and 'ubuntu' user with UID 1000 will most likely conflict with host user as well +RUN userdel --remove ubuntu + +# Disable APT ESM hook which tries to enable some systemd services on each apt invocation +RUN rm /etc/apt/apt.conf.d/20apt-esm-hook.conf + CMD /bin/bash diff --git a/Dockerfile.cuda b/Dockerfile.cuda index f457b74..da94ad6 100644 --- a/Dockerfile.cuda +++ b/Dockerfile.cuda @@ -1,15 +1,16 @@ # BASE image -ARG BASE_IMAGE=ubuntu-toolbox:22.04 +ARG BASE_IMAGE=ubuntu-toolbox:24.04 FROM ${BASE_IMAGE} # CUDA and CUDNN versions ARG CUDA_PLATFORM=ubuntu2204 -ARG CUDA_RELEASE=11-8 +ARG CUDA_RELEASE=12-2 ARG CUDNN_BRANCH=8 -ARG CUDNN_RELEASE=8.6.0.163-1+cuda11.8 +ARG CUDNN_RELEASE=8.9.7.29-1+cuda12.2 ARG BINARIES_DIR=/data/bins ARG TARGETARCH=amd64 +ARG RELEASE=24.04 RUN apt-get update && \ apt-get install -y build-essential openjdk-8-jdk && \ @@ -27,6 +28,23 @@ RUN apt-get update && \ update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-9 9 && \ update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-8 10; \ fi && \ + if [ "${CUDA_RELEASE}" = "12-2" ]; then \ + apt-get install -y gcc-12 g++-12 && \ + update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 9 && \ + update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 10 && \ + update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 9 && \ + update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 10 && \ + update-alternatives --quiet --remove cpp /usr/bin/cpp && \ + update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-13 9 && \ + update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-12 10; \ + fi && \ + # Nsight deps workaround + echo "${CUDA_PLATFORM} :: ${RELEASE}" && \ + if [ "${CUDA_PLATFORM}" = "ubuntu2204" ] && [ "${RELEASE}" = "24.04" ]; then \ + wget http://security.ubuntu.com/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_amd64.deb && \ + dpkg -i libtinfo5_6.3-2ubuntu0.1_amd64.deb && \ + rm libtinfo5_6.3-2ubuntu0.1_amd64.deb; \ + fi && \ apt clean && rm -rd /var/lib/apt/lists/* # Install CUDA and CUDNN runtime and development @@ -36,10 +54,22 @@ RUN wget \ if [ -f ${BINARIES_DIR}/faed14dd.pub ]; then \ apt-key add ${BINARIES_DIR}/faed14dd.pub; \ fi && \ - apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/${CUDA_PLATFORM}/x86_64/3bf863cc.pub && \ - add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/${CUDA_PLATFORM}/x86_64/ /" && \ + wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb && \ + dpkg -i cuda-keyring_1.1-1_all.deb && \ + rm cuda-keyring_1.1-1_all.deb && \ apt-get update && apt-get install -y cuda-toolkit-${CUDA_RELEASE} && \ - dpkg -i ${BINARIES_DIR}/libcudnn${CUDNN_BRANCH}_${CUDNN_RELEASE}_${TARGETARCH}.deb ${BINARIES_DIR}/libcudnn${CUDNN_BRANCH}-dev_${CUDNN_RELEASE}_${TARGETARCH}.deb && \ + if [ -n "${CUDNN_RELEASE}" ]; then \ + if [ -f "${BINARIES_DIR}/libcudnn${CUDNN_BRANCH}_${CUDNN_RELEASE}_${TARGETARCH}.deb" ] && \ + [ -f "${BINARIES_DIR}/libcudnn${CUDNN_BRANCH}-dev_${CUDNN_RELEASE}_${TARGETARCH}.deb" ]; then \ + dpkg -i ${BINARIES_DIR}/libcudnn${CUDNN_BRANCH}_${CUDNN_RELEASE}_${TARGETARCH}.deb \ + ${BINARIES_DIR}/libcudnn${CUDNN_BRANCH}-dev_${CUDNN_RELEASE}_${TARGETARCH}.deb; \ + else \ + apt-get install -y libcudnn${CUDNN_BRANCH}=${CUDNN_RELEASE} \ + libcudnn${CUDNN_BRANCH}-dev=${CUDNN_RELEASE}; \ + fi \ + else \ + apt-get install -y cudnn${CUDNN_BRANCH}-cuda-${CUDA_RELEASE}; \ + fi && \ apt clean && rm -rd /var/lib/apt/lists/* # Post-install configurations diff --git a/Dockerfile.dev b/Dockerfile.dev index c328d6d..3310ccd 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,13 +1,13 @@ # BASE image -ARG BASE_IMAGE=ubuntu-toolbox:22.04-cuda11.8 +ARG BASE_IMAGE=ubuntu-toolbox:24.04-cuda12.2 FROM ${BASE_IMAGE} # FFMPEG and OpenCV versions ARG CUDA_ARCH_BIN=8.6 -ARG OPENCV_RELEASE=4.6.0 -ARG FFMPEG_RELEASE=5.0.2 -ARG VIDEOSDK_RELEASE=11.1.5.2 +ARG OPENCV_RELEASE=4.9.0 +ARG FFMPEG_RELEASE=7.0 +ARG VIDEOSDK_RELEASE=12.2.72.0 WORKDIR /opt/workspace @@ -30,10 +30,10 @@ RUN apt-get update && \ RUN wget https://ffmpeg.org/releases/ffmpeg-${FFMPEG_RELEASE}.tar.gz -O ffmpeg.tar.gz && \ tar -zxvf ffmpeg.tar.gz && cd ffmpeg-${FFMPEG_RELEASE} && \ . /etc/profile.d/cuda.sh && \ - ./configure --enable-nonfree --enable-cuda-nvcc --enable-nvdec --enable-nvenc --enable-libnpp \ - --extra-cflags="-I/usr/local/cuda/include" --extra-ldflags="-L/usr/local/cuda/lib64" \ + ./configure --enable-nonfree --enable-cuda-nvcc --nvccflags="-gencode arch=compute_$( echo -n ${CUDA_ARCH_BIN} | tr -d '.'),code=sm_$(echo -n ${CUDA_ARCH_BIN} | tr -d '.') -O2" \ + --enable-nvdec --enable-nvenc --enable-libnpp --extra-cflags="-I/usr/local/cuda/include" --extra-ldflags="-L/usr/local/cuda/lib64" \ --enable-gpl --enable-gnutls --enable-libass --enable-libopus --enable-libvorbis \ - --enable-libx264 --enable-libx265 --enable-shared --enable-static --enable-libpulse && \ + --enable-libx264 --enable-libx265 --enable-shared --enable-static --enable-libpulse ; cat ffbuild/config.log && \ make -j$(nproc --ignore=4) && make install && ldconfig && make clean && \ cd .. && rm -rf FFmpeg-n${FFMPEG_RELEASE} ffmpeg.tar.gz diff --git a/Makefile b/Makefile index f903b80..6c9af71 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,22 @@ -VIDEOSDK_RELEASE ?= 9.1.23.2 -OPENCV_RELEASE ?= 4.5.5 -FFMPEG_RELEASE ?= 4.4.2 -UBUNTU_RELEASE ?= 20.04 -CUDNN_RELEASE ?= 7.6.5.32-1+cuda10.1 -CUDA_PLATFORM ?= ubuntu1804 -CUDNN_BRANCH ?= 7 -CUDA_RELEASE ?= 10-1 +VIDEOSDK_RELEASE ?= 12.2.72.0 +OPENCV_RELEASE ?= 4.9.0 +FFMPEG_RELEASE ?= 7.0 +UBUNTU_RELEASE ?= 24.04 +CUDNN_RELEASE ?= 8.9.7.29-1+cuda12.2 +CUDA_PLATFORM ?= ubuntu2204 +CUDA_ARCH_BIN ?= 8.6 +CUDNN_BRANCH ?= 8 +CUDA_RELEASE ?= 12-2 BINARIES_DIR ?= /data/bins -IMAGE ?= ubuntu-toolbox +IMAGE ?= ubuntu-toolbox .PHONY: base base: - podman build --build-arg "RELEASE=$(UBUNTU_RELEASE)" -t $(IMAGE):$(UBUNTU_RELEASE) -f Dockerfile . + podman build --rm --build-arg "RELEASE=$(UBUNTU_RELEASE)" -t $(IMAGE):$(UBUNTU_RELEASE) -f Dockerfile . .PHONY: cuda cuda: base - podman build -t $(IMAGE):$(UBUNTU_RELEASE)-cuda$(subst -,.,$(CUDA_RELEASE)) \ + podman build --rm -t $(IMAGE):$(UBUNTU_RELEASE)-cuda$(subst -,.,$(CUDA_RELEASE)) \ --build-arg "BASE_IMAGE=$(IMAGE):$(UBUNTU_RELEASE)" \ --build-arg "CUDA_PLATFORM=$(CUDA_PLATFORM)" \ --build-arg "CUDNN_RELEASE=$(CUDNN_RELEASE)" \ @@ -28,10 +29,11 @@ cuda: base .PHONY: dev dev: cuda - podman build -t $(IMAGE):$(UBUNTU_RELEASE)-dev \ + podman build --rm -t $(IMAGE):$(UBUNTU_RELEASE)-dev \ --build-arg "BASE_IMAGE=$(IMAGE):$(UBUNTU_RELEASE)-cuda$(subst -,.,$(CUDA_RELEASE))" \ --build-arg "VIDEOSDK_RELEASE=$(VIDEOSDK_RELEASE)" \ --build-arg "OPENCV_RELEASE=$(OPENCV_RELEASE)" \ --build-arg "FFMPEG_RELEASE=$(FFMPEG_RELEASE)" \ + --build-arg "CUDA_ARCH_BIN=$(CUDA_ARCH_BIN)" \ -f Dockerfile.dev . diff --git a/extra-packages b/extra-packages index 9192f67..5886046 100644 --- a/extra-packages +++ b/extra-packages @@ -10,7 +10,7 @@ zsh curl wget fonts-cantarell -libasound2 +alsa-base alsa-utils pulseaudio-utils libx11-xcb1