Fix build and install mesa during container startup

This brings the Mesa and Vulkan installation in-line with the NVIDIA driver installation for NVIDIA GPU users.
This commit is contained in:
Josh.5
2023-10-02 19:14:28 +13:00
parent c165e28f07
commit ca7521d765
2 changed files with 38 additions and 69 deletions

View File

@@ -144,43 +144,6 @@ RUN \
&& \
echo
# Install mesa and vulkan requirements
# TODO: Strip this section back to only what is required for all GPU types.
# Anything only required for Intel/AMD/NVIDIA should go in the container init.
RUN \
echo "**** Update apt database ****" \
&& dpkg --add-architecture i386 \
&& echo "deb http://deb.debian.org/debian/ sid main" > /etc/apt/sources.list \
&& apt-get update \
&& \
echo "**** Install mesa requirements ****" \
&& apt-get install -y --no-install-recommends \
libgl1-mesa-dri \
libgl1-mesa-glx \
libgles2-mesa \
libglu1-mesa \
mesa-utils \
mesa-utils-extra \
&& \
echo "**** Install vulkan requirements ****" \
&& apt-get install -y --no-install-recommends \
libvulkan1 \
libvulkan1:i386 \
mesa-vulkan-drivers \
mesa-vulkan-drivers:i386 \
vulkan-tools \
&& \
echo "**** Section cleanup ****" \
&& rm -f /etc/apt/sources.list \
&& apt-get clean autoclean -y \
&& apt-get autoremove -y \
&& rm -rf \
/var/lib/apt/lists/* \
/var/tmp/* \
/tmp/* \
&& \
echo
# Install X Server requirements
# TODO: Refine this list of packages to only what is required.
ENV \
@@ -239,7 +202,7 @@ RUN \
echo "**** Update apt database ****" \
&& apt-get update \
&& \
echo "**** Install X Server requirements ****" \
echo "**** Install pulseaudio requirements ****" \
&& apt-get install -y --no-install-recommends \
pulseaudio \
alsa-utils \
@@ -516,11 +479,12 @@ RUN \
# Install Steam
RUN \
echo "**** Update apt database ****" \
&& dpkg --add-architecture i386 \
&& apt-get update \
&& \
echo "**** Install Steam ****" \
&& apt-get install -y --no-install-recommends \
steam \
steam-installer \
&& ln -sf /usr/games/steam /usr/bin/steam \
&& \
echo "**** Section cleanup ****" \

View File

@@ -12,9 +12,11 @@ else
fi
# NVIDIA Params
export nvidia_pci_address="$(nvidia-smi --format=csv --query-gpu=pci.bus_id --id="${gpu_select:?}" 2> /dev/null | sed -n 2p | cut -d ':' -f2,3)"
export nvidia_gpu_name=$(nvidia-smi --format=csv --query-gpu=name --id="${gpu_select:?}" 2> /dev/null | sed -n 2p)
export nvidia_host_driver_version="$(nvidia-smi 2> /dev/null | grep NVIDIA-SMI | cut -d ' ' -f3)"
if [ "X${gpu_select:-}" != "X" ]; then
export nvidia_pci_address="$(nvidia-smi --format=csv --query-gpu=pci.bus_id --id="${gpu_select:?}" 2> /dev/null | sed -n 2p | cut -d ':' -f2,3)"
export nvidia_gpu_name=$(nvidia-smi --format=csv --query-gpu=name --id="${gpu_select:?}" 2> /dev/null | sed -n 2p)
export nvidia_host_driver_version="$(nvidia-smi 2> /dev/null | grep NVIDIA-SMI | cut -d ' ' -f3)"
fi
# Intel params
# This figures out if it's an intel CPU with integrated GPU
@@ -26,6 +28,7 @@ export intel_gpu_model="$(lspci | grep -i "VGA compatible controller: Intel" | c
export amd_cpu_model="$(lscpu | grep 'Model name:' | grep -i amd | cut -d':' -f2 | xargs)"
export amd_gpu_model="$(lspci | grep -i vga | grep -i amd)"
function download_driver {
mkdir -p "${USER_HOME:?}/Downloads"
chown -R ${USER:?} "${USER_HOME:?}/Downloads"
@@ -48,15 +51,6 @@ function install_nvidia_driver {
# Download the driver (if it does not yet exist locally)
download_driver
# if command -v pacman &> /dev/null; then
# echo "Install NVIDIA vulkan utils" \
# && pacman -Syu --noconfirm --needed \
# lib32-nvidia-utils \
# lib32-vulkan-icd-loader
# nvidia-utils \
# vulkan-icd-loader \
# && echo
# fi
if (($(echo $nvidia_host_driver_version | cut -d '.' -f 1) > 500)); then
echo "Installing NVIDIA driver v${nvidia_host_driver_version:?} to match what is running on the host"
chmod +x "${USER_HOME:?}/Downloads/NVIDIA_${nvidia_host_driver_version:?}.run"
@@ -146,41 +140,52 @@ function patch_nvidia_driver {
fi
}
function install_deb_mesa {
if [ ! -f /tmp/init-mesa-libs-install.log ]; then
echo " - Enable i386 arch"
dpkg --add-architecture i386
echo " - Add Debian SID sources"
echo "deb http://deb.debian.org/debian/ sid main" > /etc/apt/sources.list
apt-get update &>> /tmp/init-mesa-libs-install.log
echo " - Install mesa vulkan drivers"
echo "" >> /tmp/init-mesa-libs-install.log
apt-get install -y --no-install-recommends \
libvulkan1 \
libvulkan1:i386 \
mesa-vulkan-drivers \
mesa-vulkan-drivers:i386 \
mesa-utils \
mesa-utils-extra \
vulkan-tools \
&>> /tmp/init-mesa-libs-install.log
else
echo " - Mesa has already been installed into this container"
fi
}
function install_amd_gpu_driver {
echo "Install AMD vulkan driver"
echo "Install AMD Mesa driver"
if command -v pacman &> /dev/null; then
pacman -Syu --noconfirm --needed \
lib32-vulkan-icd-loader \
lib32-vulkan-radeon \
vulkan-icd-loader \
vulkan-radeon
# There is currently nothing to install inside the debian container. This already comes with the vulken drives that are required
# elif command -v apt-get &> /dev/null; then
# [[ "${APT_UPDATED:-false}" == 'false' ]] && apt-get update && export APT_UPDATED=true
# apt-get install -y \
# libvulkan1 \
# libvulkan1:i386 \
# mesa-vulkan-drivers \
# mesa-vulkan-drivers:i386
elif command -v apt-get &> /dev/null; then
install_deb_mesa
fi
}
function install_intel_gpu_driver {
echo "Install Intel vulkan driver"
echo "Install Intel Mesa driver"
if command -v pacman &> /dev/null; then
pacman -Syu --noconfirm --needed \
lib32-vulkan-icd-loader \
lib32-vulkan-intel \
vulkan-icd-loader \
vulkan-intel
# There is currently nothing to install inside the debian container. This already comes with the vulken drives that are required
# elif command -v apt-get &> /dev/null; then
# [[ "${APT_UPDATED:-false}" == 'false' ]] && apt-get update && export APT_UPDATED=true
# apt-get install -y \
# libvulkan1 \
# libvulkan1:i386 \
# mesa-vulkan-drivers \
# mesa-vulkan-drivers:i386
elif command -v apt-get &> /dev/null; then
install_deb_mesa
fi
}