This guide covers installing the NVIDIA drivers safely on Debian 12 in a virtualised environment (Proxmox VM, PCI passthrough), avoiding the version mismatches and breakage that come from mixed repositories or incompatible packages.
- ☑️ Use only the official Debian repositories (
deb.debian.org) — no CUDA repos, no NVIDIA.runpackages - ☑️ No experimental or third-party repositories (everything comes from Debian)
- ☑️ main, contrib, non-free and non-free-firmware ENABLED in
/etc/apt/sources.list - ☑️ System up to date
sudo apt update && sudo apt upgrade -y
sudo apt install -y curl wget sudo vim gnupg2 ca-certificates lsb-releasesudo tee /etc/apt/sources.list > /dev/null <<'EOF2'
deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
deb http://deb.debian.org/debian bookworm-backports main contrib non-free non-free-firmware
deb http://deb.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
EOF2
sudo apt updatesudo apt install -y nvidia-driver nvidia-cuda-toolkit
sudo reboot
# After the reboot:
nvidia-smi🔎 If that command shows your GPU, you're set.
sudo apt install -y ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl enable docker
sudo systemctl start docker
sudo usermod -aG docker $USER # log out and back in for this to take effectcurl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | \
sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
sudo sed -i 's|^deb |deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] |' /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt update
sudo apt install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart dockerdocker run --rm --gpus all nvidia/cuda:12.2.0-base-ubuntu22.04 nvidia-smiMake sure no extra NVIDIA/CUDA repositories crept in:
grep -Ri nvidia /etc/apt/sources.list*If the output mentions repos like developer.download.nvidia.com, remove them and then run:
sudo apt updatenvidia-smiMUST work and show the card- Docker containers MUST be able to see the GPU
- Reboot at least once and confirm the NVIDIA module loads (
lsmod | grep nvidia) - No red warnings in
dmesg/syslog/kernel - Docker and CasaOS both work
- NO other NVIDIA/CUDA repository configured
Once the base install is done, use the
NVIDIA safe driver upgrade script as the ONLY way to upgrade the driver.
Do not run a plain apt upgrade over the NVIDIA packages.
Even on a system with only official Debian repositories, upgrade the NVIDIA drivers through the dedicated safe-upgrade script only.
- For system and application updates:
apt update && apt upgrade -yas usual.
- For the NVIDIA drivers:
- Don't rely on
apt upgradealone fornvidia-driverand its related packages. - Always use nvidia_safe_upgrade.sh so that all NVIDIA package versions are aligned before the upgrade.
- This avoids problems such as:
nvidia-sminot found- NVIDIA modules not loading
- Docker/LLM workloads no longer seeing the GPU
- Don't rely on
When in doubt:
- Hold the NVIDIA packages with
apt-mark hold ... - Unhold them only for the upgrade script, then put the hold back.
sudo apt-mark hold nvidia-driver nvidia-driver-bin nvidia-driver-libs nvidia-kernel-dkms \
xserver-xorg-video-nvidia nvidia-vdpau-driver nvidia-settings libnvidia-cfg1 \
firmware-nvidia-gsp nvidia-persistencedsudo apt-mark unhold nvidia-driver nvidia-driver-bin nvidia-driver-libs nvidia-kernel-dkms \
xserver-xorg-video-nvidia nvidia-vdpau-driver nvidia-settings libnvidia-cfg1 \
firmware-nvidia-gsp nvidia-persistenced
./nvidia_safe_upgrade.sh
sudo apt-mark hold nvidia-driver nvidia-driver-bin nvidia-driver-libs nvidia-kernel-dkms \
xserver-xorg-video-nvidia nvidia-vdpau-driver nvidia-settings libnvidia-cfg1 \
firmware-nvidia-gsp nvidia-persistenced- Don't mix the CUDA repo with the Debian repo!
- If something goes wrong, roll back to the VM backup/snapshot and re-check every version.
✳️ To keep the system and the drivers aligned without surprises, use the NVIDIA safe driver upgrade script.