Skip to content

Instantly share code, notes, and snippets.

@timsonner
Last active May 15, 2026 00:13
Show Gist options
  • Select an option

  • Save timsonner/873ce84ada34416675309d5261e4c2f2 to your computer and use it in GitHub Desktop.

Select an option

Save timsonner/873ce84ada34416675309d5261e4c2f2 to your computer and use it in GitHub Desktop.
Installs NVIDIA driver 595+ on Proxmox VE / Debian trixie with kernel 7.0+ because 550 is incompatible. Blacklists Nouveau and NovaCore.
#!/bin/bash
# fix-nvidia.sh
#
# Installs NVIDIA driver 595+ on Proxmox VE / Debian trixie with kernel 7.0+.
#
# Root cause: The Debian/Proxmox nvidia-kernel-dkms package (version 550) cannot
# build against kernel 6.17+ or 7.0+ due to DRM API changes (struct_mutex removal,
# framebuffer signature changes). The official .run installer at 595.71.05+ includes
# the necessary patches.
#
# Usage:
# sudo ./fix-nvidia.sh /path/to/NVIDIA-Linux-x86_64-595.71.05.run
#
# Download the .run installer from:
# https://www.nvidia.com/en-us/drivers/ (select Linux 64-bit)
# Direct: https://download.nvidia.com/XFree86/Linux-x86_64/595.71.05/NVIDIA-Linux-x86_64-595.71.05.run
#
# Requirements:
# - Kernel 7.0.0-3-pve (or later) running
# - linux-headers for the running kernel installed
# - Internet access (for apt dependencies)
set -e
KERNEL=$(uname -r)
RUN_INSTALLER="${1:-}"
# Must run as root
if [ "$(id -u)" -ne 0 ]; then
echo "Error: run this script as root (sudo $0 <installer.run>)" >&2
exit 1
fi
NVIDIA_VER="${NVIDIA_VER:-595.71.05}"
NVIDIA_URL="https://download.nvidia.com/XFree86/Linux-x86_64/${NVIDIA_VER}/NVIDIA-Linux-x86_64-${NVIDIA_VER}.run"
# If no installer provided, offer to download it
if [ -z "$RUN_INSTALLER" ]; then
echo "No installer specified. Will download NVIDIA ${NVIDIA_VER}."
echo "URL: $NVIDIA_URL"
echo "Override version with: NVIDIA_VER=xxx sudo $0"
echo ""
RUN_INSTALLER="/tmp/NVIDIA-Linux-x86_64-${NVIDIA_VER}.run"
if [ ! -f "$RUN_INSTALLER" ]; then
if command -v wget >/dev/null 2>&1; then
wget -O "$RUN_INSTALLER" "$NVIDIA_URL"
elif command -v curl >/dev/null 2>&1; then
curl -L -o "$RUN_INSTALLER" "$NVIDIA_URL"
else
echo "Error: neither wget nor curl found. Install one or pass the .run file manually." >&2
echo "Usage: sudo $0 /path/to/NVIDIA-Linux-x86_64-${NVIDIA_VER}.run" >&2
exit 1
fi
else
echo "Found cached installer at $RUN_INSTALLER, skipping download."
fi
fi
if [ ! -f "$RUN_INSTALLER" ]; then
echo "Error: installer not found: $RUN_INSTALLER" >&2
exit 1
fi
# Verify it's executable / is an NVIDIA installer
if ! file "$RUN_INSTALLER" | grep -q 'shell script\|executable'; then
chmod +x "$RUN_INSTALLER"
fi
echo "=== Step 1: Install build dependencies ==="
apt-get install -y --no-install-recommends \
dkms \
build-essential \
"linux-headers-${KERNEL}" \
pkg-config \
libglvnd-dev
echo ""
echo "=== Step 2: Remove conflicting Debian NVIDIA packages ==="
# Stop display manager to avoid conflicts during install
DM_SERVICE=""
for dm in gdm3 gdm lightdm sddm; do
if systemctl is-active --quiet "${dm}.service" 2>/dev/null; then
DM_SERVICE="$dm"
break
fi
done
# Remove apt-managed NVIDIA packages that conflict with the .run installer
NVIDIA_PKGS=$(dpkg -l | awk '/^ii.*nvidia/{print $2}' | grep -v 'nvidia-settings\|nvidia-smi' || true)
if [ -n "$NVIDIA_PKGS" ]; then
echo "Removing: $NVIDIA_PKGS"
apt-get remove -y --purge $NVIDIA_PKGS 2>/dev/null || true
apt-get autoremove -y 2>/dev/null || true
fi
# Remove nvidia-kernel-dkms specifically (common conflict)
for pkg in nvidia-kernel-dkms nvidia-driver nvidia-legacy-check; do
if dpkg -l "$pkg" 2>/dev/null | grep -q '^ii'; then
apt-get remove -y --purge "$pkg" 2>/dev/null || true
fi
done
echo ""
echo "=== Step 3: Blacklist conflicting drivers ==="
# Blacklist nouveau
if ! grep -q 'blacklist nouveau' /etc/modprobe.d/nvidia-blacklist.conf 2>/dev/null; then
cat > /etc/modprobe.d/nvidia-blacklist.conf <<'EOF'
blacklist nouveau
options nouveau modeset=0
EOF
echo "Wrote /etc/modprobe.d/nvidia-blacklist.conf"
fi
# Unload nouveau if loaded
if lsmod | grep -q nouveau; then
echo "Unloading nouveau..."
modprobe -r nouveau 2>/dev/null || true
fi
# Blacklist NovaCore (kernel 7.0+ built-in open NVIDIA driver).
# NovaCore conflicts with the proprietary nvidia.ko and must be disabled
# for nvidia-smi, CUDA, and hashcat to work.
if [ -f "/lib/modules/${KERNEL}/kernel/drivers/gpu/nova-core/nova_core.ko" ] || \
lsmod | grep -q nova_core 2>/dev/null; then
echo "Detected NovaCore (kernel 7.0+ built-in NVIDIA driver) — blacklisting it."
echo "blacklist nova_core" > /etc/modprobe.d/novacore-blacklist.conf
echo "Wrote /etc/modprobe.d/novacore-blacklist.conf"
# Unbind from GPU if currently active so the installer can claim it
if [ -d "/sys/bus/pci/drivers/NovaCore" ]; then
for dev in /sys/bus/pci/drivers/NovaCore/*/; do
devid=$(basename "$dev")
echo "Unbinding NovaCore from $devid..."
echo "$devid" > /sys/bus/pci/drivers/NovaCore/unbind 2>/dev/null || true
done
fi
modprobe -r nova_core 2>/dev/null || true
fi
echo ""
echo "=== Step 4: Run NVIDIA installer with DKMS ==="
echo "Installer: $RUN_INSTALLER"
echo "Kernel: $KERNEL"
echo ""
echo "Note: The installer may warn about libglvnd EGL config path — this is non-fatal."
echo ""
"$RUN_INSTALLER" \
--dkms \
--no-questions \
--accept-license \
--ui=none \
--no-backup \
--kernel-name="$KERNEL"
echo ""
echo "=== Step 5: Configure module autoload and options ==="
# Load nvidia-drm with modeset=1 (required for Wayland/GBM)
echo "options nvidia-drm modeset=1" > /etc/modprobe.d/nvidia-drm.conf
echo "Wrote /etc/modprobe.d/nvidia-drm.conf"
# Autoload modules at boot
echo -e "nvidia\nnvidia-uvm\nnvidia-drm\nnvidia-modeset" > /etc/modules-load.d/nvidia.conf
echo "Wrote /etc/modules-load.d/nvidia.conf"
echo ""
echo "=== Step 6: Update initramfs ==="
update-initramfs -u -k "$KERNEL"
echo ""
echo "=== Done ==="
echo ""
# Verify
if /sbin/modinfo nvidia 2>/dev/null | grep -q "^version:"; then
NV_VER=$(/sbin/modinfo nvidia | awk '/^version:/{print $2}')
echo "NVIDIA module version: $NV_VER"
else
echo "Warning: nvidia module not found in modinfo. You may need to reboot."
fi
DKMS_STATUS=$(dkms status nvidia 2>/dev/null || echo "unknown")
echo "DKMS status: $DKMS_STATUS"
echo ""
echo "Reboot now to activate the NVIDIA driver."
echo "After reboot, verify with:"
echo " nvidia-smi # driver status and GPU info"
echo " nvidia-smi -q # full query"
echo " nvidia-smi dmon # live monitoring"
echo ""
echo "For CUDA (AI/ML): install cuda-toolkit separately:"
echo " https://developer.nvidia.com/cuda-downloads (select Linux > x86_64 > Debian > runfile)"
echo ""
echo "For hashcat: should work out of the box after reboot."
echo " hashcat -I # list OpenCL/CUDA devices"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment