Thank you for the answers. In the meantime, Iβm trying to develop a suite written in Bash that guides me through installing the GPU drivers and the CUDA Toolkit (simply because itβs a procedure that can be fairly easily automated and I donβt want to keep scattered notes around). However, the driver and CUDA Toolkit versions still have to be entered manually by the user.
Since Iβm not particularly productive with Bash (Iβm a backend PHP developer, so I write complex Bash scripts very rarely), the suite is spec-driven developed, and I also had the AI generate a test suite that allows me to mock and stub the environment so that the script believes there is actually an NVIDIA GPU to install.
However, not installing the CUDA Toolkit from the NVIDIA repository and the drivers from the repository I had initially specified was one of the first recommendations the AI gave me during the requirements gathering phase, because it can easily lead to dependency hell.
These are the scripts output so far (Iβve asked to make them really verbose by default to let the user always be informed of what is going on)
[INFO] Target: NVIDIA driver 590 on kernel 6.8.0-51-generic.
[INFO] Each step will be skipped if the desired state is already present.
ββββββββββββββββββββββββββββββββββββββββββββββ
βΊ Pre-flight 1/2 β Verify NVIDIA GPU presence
ββββββββββββββββββββββββββββββββββββββββββββββ
[OK] NVIDIA GPU detected:
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GA102 [GeForce RTX 3090] [10de:2204] (rev a1)
01:00.1 Audio device [0403]: NVIDIA Corporation GA102 High Definition Audio Controller [10de:1aef] (rev a1)
[INFO] GPU PCI device ID: 0x2204 (8708 decimal)
ββββββββββββββββββββββββββββββββββββββββββββββ
βΊ Pre-flight 2/2 β Verify gcc version matches kernel build compiler
ββββββββββββββββββββββββββββββββββββββββββββββ
[OK] gcc version matches kernel build compiler (13.3).
ββββββββββββββββββββββββββββββββββββββββββββββ
βΊ Step 1/8 β Update APT repositories
ββββββββββββββββββββββββββββββββββββββββββββββ
[INFO] Executing: sudo apt update
ββββββββββββββββββββββββββββββββββββββββββββββ
βΊ Step 2/8 β Install prerequisites (build-essential, dkms, mokutil, linux-headers)
ββββββββββββββββββββββββββββββββββββββββββββββ
[INFO] Executing: sudo apt install -y build-essential dkms mokutil linux-headers-6.8.0-51-generic
ββββββββββββββββββββββββββββββββββββββββββββββ
βΊ Checkpoint 1 β Verify kernel headers
ββββββββββββββββββββββββββββββββββββββββββββββ
[INFO] Checkpoint: linux-headers-6.8.0-51-generic installed
[OK] Checkpoint βlinux-headers-6.8.0-51-generic installedβ passed.
ββββββββββββββββββββββββββββββββββββββββββββββ
βΊ Step 3/8 β Blacklist nouveau driver
ββββββββββββββββββββββββββββββββββββββββββββββ
[SKIP] nouveau already blacklisted in /tmp/tmp.jbnWH3IEGr/etc/modprobe.d/blacklist-nouveau.conf β skipping.
ββββββββββββββββββββββββββββββββββββββββββββββ
βΊ Repository setup β NVIDIA official APT repo (cuda-keyring)
ββββββββββββββββββββββββββββββββββββββββββββββ
[INFO] Detected distribution identifier: ubuntu2404
[INFO] Downloading NVIDIA keyring: https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb
[INFO] Executing: wget -q --show-progress https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb -O /tmp/cuda-keyring_1.1-1_all.deb
[INFO] Executing: sudo dpkg -i /tmp/cuda-keyring_1.1-1_all.deb
[INFO] Executing: sudo apt update
[OK] NVIDIA official repository configured.
ββββββββββββββββββββββββββββββββββββββββββββββ
βΊ Step 5/8 β Remove conflicting NVIDIA packages (preserving CUDA Toolkit)
ββββββββββββββββββββββββββββββββββββββββββββββ
[INFO] No existing NVIDIA driver found β proceeding with fresh installation.
[INFO] Purging nvidia* and libnvidia* (cuda* intentionally excluded)β¦
[INFO] Executing: sudo apt autoremove -y
ββββββββββββββββββββββββββββββββββββββββββββββ
βΊ Step 6/8 β Install nvidia driver 590
ββββββββββββββββββββββββββββββββββββββββββββββ
[INFO] Ampere or newer GPU detected β installing open kernel modules (nvidia-open).
[INFO] Executing: sudo apt install -y nvidia-open-590 nvidia-dkms-590
ββββββββββββββββββββββββββββββββββββββββββββββ
βΊ Checkpoint 2 β Verify DKMS module status (expected: βinstalledβ)
ββββββββββββββββββββββββββββββββββββββββββββββ
[OK] DKMS status: OK
nvidia/570.86.16, 6.8.0-51-generic, x86_64: installed
ββββββββββββββββββββββββββββββββββββββββββββββ
βΊ Step 7/8 β Sign nvidia.ko with MOK key
ββββββββββββββββββββββββββββββββββββββββββββββ
[INFO] Found module at: /tmp/tmp.jbnWH3IEGr/lib/modules/6.8.0-51-generic/updates/dkms/nvidia.ko.zst
[INFO] Module is ZST-compressed β decompressing before signingβ¦
[INFO] Executing: sudo zstd -d --rm /tmp/tmp.jbnWH3IEGr/lib/modules/6.8.0-51-generic/updates/dkms/nvidia.ko.zst -o /tmp/tmp.jbnWH3IEGr/lib/modules/6.8.0-51-generic/updates/dkms/nvidia.ko
[INFO] Executing: sudo kmodsign sha512 /tmp/tmp.jbnWH3IEGr/var/lib/shim-signed/mok/MOK.priv /tmp/tmp.jbnWH3IEGr/var/lib/shim-signed/mok/MOK.der /tmp/tmp.jbnWH3IEGr/lib/modules/6.8.0-51-generic/updates/dkms/nvidia.ko
[OK] Module signed.
[INFO] Recompressing signed module back to ZST (default compression level)β¦
[INFO] Executing: sudo zstd --rm /tmp/tmp.jbnWH3IEGr/lib/modules/6.8.0-51-generic/updates/dkms/nvidia.ko -o /tmp/tmp.jbnWH3IEGr/lib/modules/6.8.0-51-generic/updates/dkms/nvidia.ko.zst
ββββββββββββββββββββββββββββββββββββββββββββββ
βΊ Step 8/8 β Register MOK key with firmware (mokutil)
ββββββββββββββββββββββββββββββββββββββββββββββ
[SKIP] You will be prompted to set a one-time password.
[SKIP] Enter this password in the MOK Manager screen that appears on next boot.
[INFO] Executing: sudo mokutil --import /tmp/tmp.jbnWH3IEGr/var/lib/shim-signed/mok/MOK.der
input password:
input password again:
[OK] NVIDIA driver 590 installed and kernel module signed.
[INFO] After rebooting, run: ./ubuntu-installer check-driver to verify the installation.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β A system reboot is required to complete the setup. β
β Run: sudo reboot β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
[INFO] Target: CUDA Toolkit 12.8.
[INFO] Each step will be skipped if the desired state is already present.
ββββββββββββββββββββββββββββββββββββββββββββββ
βΊ Repository setup β NVIDIA official APT repo (cuda-keyring)
ββββββββββββββββββββββββββββββββββββββββββββββ
[INFO] Detected distribution identifier: ubuntu2404
[INFO] Downloading NVIDIA keyring: https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb
[INFO] Executing: wget -q --show-progress https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb -O /tmp/cuda-keyring_1.1-1_all.deb
[INFO] Executing: sudo dpkg -i /tmp/cuda-keyring_1.1-1_all.deb
[INFO] Executing: sudo apt update
[OK] NVIDIA official repository configured.
ββββββββββββββββββββββββββββββββββββββββββββββ
βΊ Step 2/7 β Install cuda-toolkit-12-8
ββββββββββββββββββββββββββββββββββββββββββββββ
[INFO] Executing: sudo apt install -y cuda-toolkit-12-8
ββββββββββββββββββββββββββββββββββββββββββββββ
βΊ Checkpoint 3 β Verify nvcc binary
ββββββββββββββββββββββββββββββββββββββββββββββ
[INFO] Checkpoint: nvcc binary at /tmp/tmp.jbnWH3IEGr/usr/local/cuda-12.8/bin/nvcc
[OK] Checkpoint βnvcc binary at /tmp/tmp.jbnWH3IEGr/usr/local/cuda-12.8/bin/nvccβ passed.
ββββββββββββββββββββββββββββββββββββββββββββββ
βΊ Step 3/7 β Configure PATH and LD_LIBRARY_PATH (system-wide)
ββββββββββββββββββββββββββββββββββββββββββββββ
[SKIP] /tmp/tmp.jbnWH3IEGr/etc/profile.d/cuda.sh already configured for CUDA 12.8 β skipping.
ββββββββββββββββββββββββββββββββββββββββββββββ
βΊ Step 4/7 β Enable nvidia-persistenced
ββββββββββββββββββββββββββββββββββββββββββββββ
[INFO] Executing: sudo systemctl enable nvidia-persistenced
[INFO] Executing: sudo systemctl start nvidia-persistenced
ββββββββββββββββββββββββββββββββββββββββββββββ
βΊ Step 5/7 β Enable GPU System Processor (GSP) firmware
ββββββββββββββββββββββββββββββββββββββββββββββ
[INFO] Detected Ampere or newer GPU (device ID: 2204) β applying GSP firmware options.
[SKIP] /tmp/tmp.jbnWH3IEGr/etc/modprobe.d/nvidia-gsp.conf already contains all GSP options β skipping.
ββββββββββββββββββββββββββββββββββββββββββββββ
βΊ Step 6/7 β Apply kernel tuning parameters (vm.swappiness, vm.max_map_count)
ββββββββββββββββββββββββββββββββββββββββββββββ
[SKIP] vm.swappiness=10 already in /tmp/tmp.jbnWH3IEGr/etc/sysctl.conf β skipping.
[SKIP] vm.max_map_count already set in /tmp/tmp.jbnWH3IEGr/etc/sysctl.conf (current live value: 65530) β skipping.
[INFO] Executing: sudo sysctl -p
ββββββββββββββββββββββββββββββββββββββββββββββ
βΊ Step 7/7 β CUDA Toolkit 12.8 installation complete
ββββββββββββββββββββββββββββββββββββββββββββββ
[OK] CUDA Toolkit 12.8 installed and configured.
[INFO] After rebooting, run: ./ubuntu-installer check-cuda to verify the installation.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β A system reboot is required to complete the setup. β
β Run: sudo reboot β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ