nvidia menu & management updates

- Refined `_show_nvidia_version_menu` in `modules/gpu/nvidia.sh` for Debian 12/13 with precise labels ("Newest Stable", "Kepler Support") and explicit official repo recommendations.
- Introduced new standalone module `modules/gpu/nvidia_manage.sh` integrated into the dispatcher to handle driver lifecycle management (Install/Change vs Remove) before version selection.
- Implemented safe removal logic (`_nvidia_remove`) with explicit package purging, explicitly excluding `firmware-misc-nonfree`, and cleaning specific configs/repos without wildcards.
- Ensured idempotency across all steps using `|| true` and preserved user CUDA toolkits while restoring Nouveau via initramfs regeneration.
This commit is contained in:
stornic56
2026-08-07 23:43:29 -05:00
committed by GitHub
parent 59c93ba459
commit f0be860f98
3 changed files with 68 additions and 7 deletions
+5
View File
@@ -5,6 +5,7 @@ _GPU_DIR="${MODULES_DIR}/gpu"
source "${_GPU_DIR}/_helpers.sh" source "${_GPU_DIR}/_helpers.sh"
source "${_GPU_DIR}/amd_intel.sh" source "${_GPU_DIR}/amd_intel.sh"
source "${_GPU_DIR}/nvidia.sh" source "${_GPU_DIR}/nvidia.sh"
source "${_GPU_DIR}/nvidia_manage.sh"
# Consumed by gaming.sh to know which NVIDIA driver path was taken # Consumed by gaming.sh to know which NVIDIA driver path was taken
NVIDIA_DRIVER_MODE="" NVIDIA_DRIVER_MODE=""
@@ -193,6 +194,10 @@ _install_nvidia_stack() {
NVIDIA_DRIVER_MODE="" NVIDIA_DRIVER_MODE=""
if ! _nvidia_manage_menu; then
return
fi
if [ "$DEBIAN_VERSION" = "11" ]; then if [ "$DEBIAN_VERSION" = "11" ]; then
install_nvidia_bullseye install_nvidia_bullseye
+7 -7
View File
@@ -195,14 +195,14 @@ _is_cuda_repo_ready() {
_show_nvidia_version_menu() { _show_nvidia_version_menu() {
local choice local choice
if [ "$DEBIAN_VERSION" = "12" ]; then if [ "$DEBIAN_VERSION" = "12" ]; then
choice=$(_menu "NVIDIA Driver Version" "Select the NVIDIA driver version for Debian 12 (Bookworm):" 12 70 3 \ choice=$(_menu "Select NVIDIA Driver for Debian 12 (Bookworm):" "Choose the NVIDIA driver version:" 12 70 3 \
"535" "Official NVIDIA driver (Recommended)" \ "535" "v535 — Debian Official (Recommended)" \
"470" "Legacy 470 (Kepler/Tesla GPUs)") "470" "v470 — Debian Legacy (Kepler Support)")
elif [ "$DEBIAN_VERSION" = "13" ]; then elif [ "$DEBIAN_VERSION" = "13" ]; then
choice=$(_menu "NVIDIA Driver Version" "Select the NVIDIA driver version for Debian 13 (Trixie):" 14 70 5 \ choice=$(_menu "Select NVIDIA Driver for Debian 13 (Trixie):" "Choose the NVIDIA driver version:" 14 70 5 \
"550" "Official Debian driver (Recommended)" \ "550" "v550 — Debian Official (Recommended)" \
"590" "NVIDIA Repo v590 (Turing/Ampere/Ada/Blackwell)" \ "590" "v590 — NVIDIA CUDA Repo (Production Branch)" \
"595" "NVIDIA Repo v595 (Latest)") "595" "v595 — NVIDIA CUDA Repo (Newest Stable)")
else else
NVIDIA_SELECTED_VERSION="auto" NVIDIA_SELECTED_VERSION="auto"
return 0 return 0
+56
View File
@@ -0,0 +1,56 @@
#!/usr/bin/env bash
# nvidia_manage.sh — NVIDIA management menu: install/change or remove
_nvidia_manage_menu() {
local choice
choice=$(_menu "NVIDIA Driver" "Manage NVIDIA Driver" 12 70 4 \
"1" "Install / Change NVIDIA Driver Version" \
"2" "Remove NVIDIA Driver and Restore Nouveau")
[ -z "$choice" ] && {
echo "Skipping NVIDIA installation."
return 1
}
case "$choice" in
2)
_nvidia_remove
return 1
;;
*) return 0 ;;
esac
}
_nvidia_remove() {
if ! dpkg -l 2>/dev/null | grep -qE "^ii (nvidia-driver|nvidia-tesla-470-driver|nvidia-open-kernel-dkms|nvidia-kernel-dkms)"; then
echo -e "${YELLOW}NVIDIA driver is not installed on this system.${NC}"
return 0
fi
if ! _confirm "Remove NVIDIA" "This will:\n - Purge the NVIDIA driver packages\n - Remove script-generated configs\n - Remove the CUDA repo sources\n - Regenerate initramfs\n\nProceed?"; then
echo "NVIDIA removal cancelled."
return 0
fi
echo "Removing NVIDIA driver packages..."
sudo apt purge -y nvidia-driver nvidia-kernel-dkms nvidia-open-kernel-dkms nvidia-tesla-470-driver nvidia-settings nvidia-vaapi-driver firmware-nvidia-gsp mesa-vdpau-drivers || true
echo "Cleaning up dependencies..."
sudo apt autoremove --purge -y || true
echo "Removing script-generated configuration..."
sudo rm -f /etc/modprobe.d/nvidia-wayland.conf || true
sudo rm -f /etc/modprobe.d/nvidia-open.conf || true
sudo rm -f /etc/apt/preferences.d/block-nvidia || true
sudo rm -f /etc/X11/xorg.conf.d/20-nvidia.conf || true
echo "Removing NVIDIA repository sources..."
sudo rm -f /etc/apt/sources.list.d/cuda-*.list || true
sudo rm -f /etc/apt/sources.list.d/extrepo_nvidia-cuda.sources || true
echo "Regenerating initramfs..."
sudo update-initramfs -u || true
echo -e "${GREEN}NVIDIA driver removed. Please reboot your system.${NC}"
return 0
}