From 5f71027be29db82219132d55abfca51ae637bbc5 Mon Sep 17 00:00:00 2001 From: Seungmin Kim <8457324+ehfd@users.noreply.github.com> Date: Thu, 27 Jun 2024 15:59:20 +0900 Subject: [PATCH] Fix installation --- Dockerfile | 12 +++++++++--- entrypoint.sh | 41 ++++++++++++++++++++++------------------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/Dockerfile b/Dockerfile index 90f9c4b..9d6acee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -136,6 +136,11 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ xserver-xorg-video-all \ xserver-xorg-video-intel \ xserver-xorg-video-qxl \ + # NVIDIA driver installer dependencies + kmod \ + libc6-dev \ + libpci3 \ + libelf-dev \ # OpenGL libraries libxau6 \ libxdmcp6 \ @@ -195,6 +200,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ vdpau-driver-all:i386 \ mesa-vulkan-drivers:i386 \ libvulkan-dev:i386 \ + libc6:i386 \ libxau6:i386 \ libxdmcp6:i386 \ libxcb1:i386 \ @@ -444,10 +450,10 @@ Pin-Priority: -1" > /etc/apt/preferences.d/firefox-nosnap && \ libreoffice-kf5 \ libreoffice-plasma \ libreoffice-style-breeze && \ - # Ensure Firefox as the default web browser - update-alternatives --set x-www-browser /usr/bin/firefox && xdg-settings set default-web-browser firefox.desktop && \ # Install Google Chrome for supported architectures - if [ "$(dpkg --print-architecture)" = "amd64" ]; then cd /tmp && curl -o google-chrome-stable.deb -fsSL "https://dl.google.com/linux/direct/google-chrome-stable_current_$(dpkg --print-architecture).deb" && apt-get update && apt-get install --no-install-recommends -y ./google-chrome-stable.deb && rm -f google-chrome-stable.deb && sed -i '/^Exec=/ s/$/ --password-store=basic/' /usr/share/applications/google-chrome.desktop; fi && \ + if [ "$(dpkg --print-architecture)" = "amd64" ]; then cd /tmp && curl -o google-chrome-stable.deb -fsSL "https://dl.google.com/linux/direct/google-chrome-stable_current_$(dpkg --print-architecture).deb" && apt-get update && apt-get install --no-install-recommends -y ./google-chrome-stable.deb && rm -f google-chrome-stable.deb && sed -i '/^Exec=/ s/$/ --password-store=basic --in-process-gpu/' /usr/share/applications/google-chrome.desktop; fi && \ + # Ensure Firefox as the default web browser + update-alternatives --set x-www-browser /usr/bin/firefox && \ apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/debconf/* /var/log/* /tmp/* /var/tmp/* && \ # Fix KDE startup permissions issues in containers MULTI_ARCH=$(dpkg --print-architecture | sed -e 's/arm64/aarch64-linux-gnu/' -e 's/armhf/arm-linux-gnueabihf/' -e 's/riscv64/riscv64-linux-gnu/' -e 's/ppc64el/powerpc64le-linux-gnu/' -e 's/s390x/s390x-linux-gnu/' -e 's/i.*86/i386-linux-gnu/' -e 's/amd64/x86_64-linux-gnu/' -e 's/unknown/x86_64-linux-gnu/') && \ diff --git a/entrypoint.sh b/entrypoint.sh index 7779130..db169a9 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -39,8 +39,8 @@ export PIPEWIRE_RUNTIME_DIR="${PIPEWIRE_RUNTIME_DIR:-${XDG_RUNTIME_DIR:-/tmp}}" export PULSE_RUNTIME_PATH="${PULSE_RUNTIME_PATH:-${XDG_RUNTIME_DIR:-/tmp}/pulse}" export PULSE_SERVER="${PULSE_SERVER:-unix:${PULSE_RUNTIME_PATH:-${XDG_RUNTIME_DIR:-/tmp}/pulse}/native}" +# Install NVIDIA userspace driver components including X graphic libraries, keep contents except outermost if condition same as docker-nvidia-glx-desktop if [ -z "$(ldconfig -p | grep 'libEGL_nvidia.so.0')" ] || [ -z "$(ldconfig -p | grep 'libGLX_nvidia.so.0')" ]; then - # Install NVIDIA userspace driver components including X graphic libraries, keep contents same as docker-nvidia-glx-desktop export NVIDIA_DRIVER_ARCH="$(dpkg --print-architecture | sed -e 's/arm64/aarch64/' -e 's/armhf/32bit-ARM/' -e 's/i.*86/x86/' -e 's/amd64/x86_64/' -e 's/unknown/x86_64/')" if [ -z "${NVIDIA_DRIVER_VERSION}" ]; then # Driver version is provided by the kernel through the container toolkit, prioritize kernel driver version if available @@ -50,31 +50,34 @@ if [ -z "$(ldconfig -p | grep 'libEGL_nvidia.so.0')" ] || [ -z "$(ldconfig -p | # Use NVIDIA-SMI when not available export NVIDIA_DRIVER_VERSION="$(nvidia-smi --version | grep 'DRIVER version' | cut -d: -f2 | tr -d ' ')" else - echo "Failed to find NVIDIA GPU driver version. You might not be using the NVIDIA container toolkit. Exiting." - exit 1 + echo 'Failed to find NVIDIA GPU driver version, container will likely not start because of no NVIDIA container toolkit or NVIDIA GPU driver present' fi fi cd /tmp # If version is different, new installer will overwrite the existing components if [ ! -f "/tmp/NVIDIA-Linux-${NVIDIA_DRIVER_ARCH}-${NVIDIA_DRIVER_VERSION}.run" ]; then # Check multiple sources in order to probe both consumer and datacenter driver versions - curl -fsSL -O "https://international.download.nvidia.com/XFree86/Linux-${NVIDIA_DRIVER_ARCH}/${NVIDIA_DRIVER_VERSION}/NVIDIA-Linux-${NVIDIA_DRIVER_ARCH}-${NVIDIA_DRIVER_VERSION}.run" || curl -fsSL -O "https://international.download.nvidia.com/tesla/${NVIDIA_DRIVER_VERSION}/NVIDIA-Linux-${NVIDIA_DRIVER_ARCH}-${NVIDIA_DRIVER_VERSION}.run" || { echo "Failed NVIDIA GPU driver download. Exiting."; exit 1; } + curl -fsSL -O "https://international.download.nvidia.com/XFree86/Linux-${NVIDIA_DRIVER_ARCH}/${NVIDIA_DRIVER_VERSION}/NVIDIA-Linux-${NVIDIA_DRIVER_ARCH}-${NVIDIA_DRIVER_VERSION}.run" || curl -fsSL -O "https://international.download.nvidia.com/tesla/${NVIDIA_DRIVER_VERSION}/NVIDIA-Linux-${NVIDIA_DRIVER_ARCH}-${NVIDIA_DRIVER_VERSION}.run" || echo 'Failed NVIDIA GPU driver download' + fi + if [ -f "/tmp/NVIDIA-Linux-${NVIDIA_DRIVER_ARCH}-${NVIDIA_DRIVER_VERSION}.run" ]; then + # Extract installer before installing + sh "NVIDIA-Linux-${NVIDIA_DRIVER_ARCH}-${NVIDIA_DRIVER_VERSION}.run" -x + cd "NVIDIA-Linux-${NVIDIA_DRIVER_ARCH}-${NVIDIA_DRIVER_VERSION}" + # Run NVIDIA driver installation without the kernel modules and host components + sudo ./nvidia-installer --silent \ + --accept-license \ + --no-kernel-module \ + --install-compat32-libs \ + --no-nouveau-check \ + --no-nvidia-modprobe \ + --no-systemd \ + --no-rpms \ + --no-backup \ + --no-check-for-alternate-installs + rm -rf /tmp/NVIDIA* && cd ~ + else + echo 'Unless using non-NVIDIA GPUs, container will likely not work correctly' fi - # Extract installer before installing - sh "NVIDIA-Linux-${NVIDIA_DRIVER_ARCH}-${NVIDIA_DRIVER_VERSION}.run" -x - cd "NVIDIA-Linux-${NVIDIA_DRIVER_ARCH}-${NVIDIA_DRIVER_VERSION}" - # Run NVIDIA driver installation without the kernel modules and host components - sudo ./nvidia-installer --silent \ - --accept-license \ - --no-kernel-module \ - --install-compat32-libs \ - --no-nouveau-check \ - --no-nvidia-modprobe \ - --no-systemd \ - --no-rpms \ - --no-backup \ - --no-check-for-alternate-installs - rm -rf /tmp/NVIDIA* && cd ~ fi # Run Xvfb server with required extensions