Skip to content

Commit

Permalink
Fix installation
Browse files Browse the repository at this point in the history
  • Loading branch information
ehfd authored Jun 27, 2024
1 parent 9ccc16b commit 5f71027
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
12 changes: 9 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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/') && \
Expand Down
41 changes: 22 additions & 19 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 5f71027

Please sign in to comment.