Run NVIDIA driver download attempts in a loop
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
|
||||
# Fech NVIDIA GPU device (if one exists)
|
||||
if [ "${NVIDIA_VISIBLE_DEVICES:-}" = "all" ]; then
|
||||
export gpu_select=$(nvidia-smi --format=csv --query-gpu=uuid 2> /dev/null | sed -n 2p)
|
||||
export gpu_select=$(nvidia-smi --format=csv --query-gpu=uuid 2>/dev/null | sed -n 2p)
|
||||
elif [ "${NVIDIA_VISIBLE_DEVICES:-}X" = "X" ]; then
|
||||
export gpu_select=$(nvidia-smi --format=csv --query-gpu=uuid 2> /dev/null | sed -n 2p)
|
||||
export gpu_select=$(nvidia-smi --format=csv --query-gpu=uuid 2>/dev/null | sed -n 2p)
|
||||
else
|
||||
export gpu_select=$(nvidia-smi --format=csv --id=$(echo "$NVIDIA_VISIBLE_DEVICES" | cut -d ',' -f1) --query-gpu=uuid | sed -n 2p)
|
||||
if [ "${gpu_select:-}X" = "X" ]; then
|
||||
export gpu_select=$(nvidia-smi --format=csv --query-gpu=uuid 2> /dev/null | sed -n 2p)
|
||||
export gpu_select=$(nvidia-smi --format=csv --query-gpu=uuid 2>/dev/null | sed -n 2p)
|
||||
fi
|
||||
fi
|
||||
|
||||
# NVIDIA Params
|
||||
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)"
|
||||
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
|
||||
@@ -28,7 +28,6 @@ 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 {
|
||||
local driver_url
|
||||
local stripped_version
|
||||
@@ -39,45 +38,36 @@ function download_driver {
|
||||
if [[ ! -f "${USER_HOME:?}/Downloads/NVIDIA_${nvidia_host_driver_version:?}.run" ]]; then
|
||||
print_step_header "Downloading driver v${nvidia_host_driver_version:?}"
|
||||
|
||||
# Try downloading from NVIDIA Global Server
|
||||
driver_url="http://download.nvidia.com/XFree86/Linux-x86_64/${nvidia_host_driver_version:?}/NVIDIA-Linux-x86_64-${nvidia_host_driver_version:?}.run"
|
||||
if wget --spider --quiet "${driver_url:?}"; then
|
||||
wget -q --show-progress --progress=bar:force:noscroll \
|
||||
-O /tmp/NVIDIA.run \
|
||||
"${driver_url:?}"
|
||||
else
|
||||
print_warning "Unable to download driver from NVIDIA Global Server. Trying US Server..."
|
||||
# Try downloading from a list of NVIDIA driver hosting servers
|
||||
stripped_version="${nvidia_host_driver_version#v}" # Strip 'v' if present
|
||||
declare -a sources=(
|
||||
"http://download.nvidia.com/XFree86/Linux-x86_64/${nvidia_host_driver_version}/NVIDIA-Linux-x86_64-${nvidia_host_driver_version}.run"
|
||||
"http://us.download.nvidia.com/XFree86/Linux-x86_64/${nvidia_host_driver_version}/NVIDIA-Linux-x86_64-${nvidia_host_driver_version}.run"
|
||||
"https://github.com/flathub/org.freedesktop.Platform.GL.nvidia/releases/download/cuda/NVIDIA-Linux-x86_64-${stripped_version}.run"
|
||||
)
|
||||
|
||||
# If NVIDIA Global Server fails, try the US server
|
||||
driver_url="http://us.download.nvidia.com/XFree86/Linux-x86_64/${nvidia_host_driver_version:?}/NVIDIA-Linux-x86_64-${nvidia_host_driver_version:?}.run"
|
||||
if wget --spider --quiet "${driver_url:?}"; then
|
||||
wget -q --show-progress --progress=bar:force:noscroll \
|
||||
for driver_url in "${sources[@]}"; do
|
||||
if wget -q --show-progress --progress=bar:force:noscroll \
|
||||
-O /tmp/NVIDIA.run \
|
||||
"${driver_url:?}"
|
||||
"${driver_url:?}"; then
|
||||
mv /tmp/NVIDIA.run "${USER_HOME:?}/Downloads/NVIDIA_${nvidia_host_driver_version:?}.run"
|
||||
return 0
|
||||
mv /tmp/NVIDIA.run "${USER_HOME:?}/Downloads/NVIDIA_${nvidia_host_driver_version:?}.run"
|
||||
return 0
|
||||
else
|
||||
print_warning "Unable to download driver from NVIDIA US Server. Trying GitHub..."
|
||||
print_warning "Download failed from: ${driver_url}"
|
||||
fi
|
||||
done
|
||||
|
||||
# Finally, if both fail, try downloading from GitHub
|
||||
stripped_version="${nvidia_host_driver_version#v}" # Strip 'v' from the version if present
|
||||
driver_url="https://github.com/flathub/org.freedesktop.Platform.GL.nvidia/releases/download/cuda/NVIDIA-Linux-x86_64-${stripped_version:?}.run"
|
||||
if wget --spider --quiet "${driver_url:?}"; then
|
||||
wget -q --show-progress --progress=bar:force:noscroll \
|
||||
-O /tmp/NVIDIA.run \
|
||||
"${driver_url:?}"
|
||||
else
|
||||
print_error "Unable to download driver from any source. Exit!"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
mv /tmp/NVIDIA.run "${USER_HOME:?}/Downloads/NVIDIA_${nvidia_host_driver_version:?}.run"
|
||||
fi
|
||||
}
|
||||
|
||||
function install_nvidia_driver {
|
||||
# Check here if the currently installed version matches using nvidia-settings
|
||||
nvidia_settings_version=$(nvidia-settings --version 2> /dev/null | grep version | cut -d ' ' -f 4)
|
||||
nvidia_settings_version=$(nvidia-settings --version 2>/dev/null | grep version | cut -d ' ' -f 4)
|
||||
if [ "${nvidia_settings_version:-}X" != "${nvidia_host_driver_version:-}X" ]; then
|
||||
# Download the driver (if it does not yet exist locally)
|
||||
download_driver
|
||||
@@ -106,7 +96,7 @@ function install_nvidia_driver {
|
||||
--no-check-for-alternate-installs \
|
||||
--no-libglx-indirect \
|
||||
--no-install-libglvnd \
|
||||
> "${USER_HOME:?}/Downloads/nvidia_gpu_install.log" 2>&1
|
||||
>"${USER_HOME:?}/Downloads/nvidia_gpu_install.log" 2>&1
|
||||
else
|
||||
print_step_header "Installing Legacy 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"
|
||||
@@ -127,7 +117,7 @@ function install_nvidia_driver {
|
||||
--no-check-for-alternate-installs \
|
||||
--no-libglx-indirect \
|
||||
--no-install-libglvnd \
|
||||
> "${USER_HOME:?}/Downloads/nvidia_gpu_install.log" 2>&1
|
||||
>"${USER_HOME:?}/Downloads/nvidia_gpu_install.log" 2>&1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@@ -155,20 +145,26 @@ function patch_nvidia_driver {
|
||||
"${USER_HOME:?}/Downloads/nvidia-patch-fbc.${NVIDIA_PATCH_VERSION:?}.sh"
|
||||
|
||||
print_step_header "Install NVIDIA driver patches"
|
||||
echo "/patched-lib" > /etc/ld.so.conf.d/000-patched-lib.conf
|
||||
echo "/patched-lib" >/etc/ld.so.conf.d/000-patched-lib.conf
|
||||
mkdir -p "/patched-lib"
|
||||
PATCH_OUTPUT_DIR="/patched-lib" "${USER_HOME:?}/Downloads/nvidia-patch.${NVIDIA_PATCH_VERSION:?}.sh"
|
||||
PATCH_OUTPUT_DIR="/patched-lib" "${USER_HOME:?}/Downloads/nvidia-patch-fbc.${NVIDIA_PATCH_VERSION:?}.sh"
|
||||
|
||||
pushd "/patched-lib" &> /dev/null || { print_error "Failed to push directory to /patched-lib"; exit 1; }
|
||||
for f in * ; do
|
||||
pushd "/patched-lib" &>/dev/null || {
|
||||
print_error "Failed to push directory to /patched-lib"
|
||||
exit 1
|
||||
}
|
||||
for f in *; do
|
||||
suffix="${f##*.so}"
|
||||
name="$(basename "$f" "$suffix")"
|
||||
[ -h "$name" ] || ln -sf "$f" "$name"
|
||||
[ -h "$name" ] || ln -sf "$f" "$name.1"
|
||||
done
|
||||
ldconfig
|
||||
popd &> /dev/null || { print_error "Failed to pop directory out of /patched-lib"; exit 1; }
|
||||
popd &>/dev/null || {
|
||||
print_error "Failed to pop directory out of /patched-lib"
|
||||
exit 1
|
||||
}
|
||||
)
|
||||
else
|
||||
print_step_header "Leaving NVIDIA driver stock without patching"
|
||||
@@ -181,11 +177,11 @@ function install_deb_mesa {
|
||||
dpkg --add-architecture i386
|
||||
if [ "${ENABLE_SID:-}" = "true" ]; then
|
||||
print_step_header "Add Debian SID sources"
|
||||
echo "deb http://deb.debian.org/debian/ sid main" > /etc/apt/sources.list
|
||||
echo "deb http://deb.debian.org/debian/ sid main" >/etc/apt/sources.list
|
||||
fi
|
||||
apt-get update &>> /tmp/init-mesa-libs-install.log
|
||||
apt-get update &>>/tmp/init-mesa-libs-install.log
|
||||
print_step_header "Install mesa vulkan drivers"
|
||||
echo "" >> /tmp/init-mesa-libs-install.log
|
||||
echo "" >>/tmp/init-mesa-libs-install.log
|
||||
apt-get install -y --no-install-recommends \
|
||||
libvulkan1 \
|
||||
libvulkan1:i386 \
|
||||
@@ -194,34 +190,34 @@ function install_deb_mesa {
|
||||
mesa-utils \
|
||||
mesa-utils-extra \
|
||||
vulkan-tools \
|
||||
&>> /tmp/init-mesa-libs-install.log
|
||||
&>>/tmp/init-mesa-libs-install.log
|
||||
else
|
||||
print_step_header "Mesa has already been installed into this container"
|
||||
fi
|
||||
}
|
||||
|
||||
function install_amd_gpu_driver {
|
||||
if command -v pacman &> /dev/null; then
|
||||
if command -v pacman &>/dev/null; then
|
||||
print_step_header "Install AMD Mesa driver"
|
||||
pacman -Syu --noconfirm --needed \
|
||||
lib32-vulkan-icd-loader \
|
||||
lib32-vulkan-radeon \
|
||||
vulkan-icd-loader \
|
||||
vulkan-radeon
|
||||
elif command -v apt-get &> /dev/null; then
|
||||
elif command -v apt-get &>/dev/null; then
|
||||
install_deb_mesa
|
||||
fi
|
||||
}
|
||||
|
||||
function install_intel_gpu_driver {
|
||||
if command -v pacman &> /dev/null; then
|
||||
if command -v pacman &>/dev/null; then
|
||||
print_step_header "Install Intel Mesa driver"
|
||||
pacman -Syu --noconfirm --needed \
|
||||
lib32-vulkan-icd-loader \
|
||||
lib32-vulkan-intel \
|
||||
vulkan-icd-loader \
|
||||
vulkan-intel
|
||||
elif command -v apt-get &> /dev/null; then
|
||||
elif command -v apt-get &>/dev/null; then
|
||||
install_deb_mesa
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user