Installs NVIDIA GPU drivers via DNF module streams on RHEL 9 systems using DKMS.
This is a minimal driver install through the package nvidia-driver-cuda without any extras shipped by the whole nvidia-driver-module.
The role can update and downgrade driver versions (through nvidia_module_stream), if you do not need the specific driver version but only the stream.
- Upgrades all system packages and reboots if needed (optional)
- Installs kernel headers, DKMS, and other prerequisites
- Blacklists the nouveau driver and rebuilds initramfs
- Adds the NVIDIA CUDA repository, installs the driver, then disables the repo
- Reboots to load the NVIDIA kernel module
- Verifies the driver is loaded via
nvidia-smi
- RHEL 9 (or compatible: Rocky, Alma, CentOS)
- A host with an NVIDIA GPU
| Variable | Default | Description |
|---|---|---|
nvidia_module_stream |
"590-dkms" |
DNF module stream for nvidia-driver |
nvidia_driver_version |
"" |
Pin a specific driver version. Empty = latest from stream |
nvidia_cuda_repo_url |
"http://developer.download.nvidia.com/compute/cuda/repos/rhel9/{{ ansible_facts['architecture'] }}" |
NVIDIA CUDA repository URL |
nvidia_cuda_repo_gpg_key |
https://developer.download.nvidia.com/compute/cuda/repos/rhel9/{{ ansible_facts['architecture'] }}/D42D0685.pub |
GPG key for the CUDA repository |
nvidia_system_upgrade |
true |
Whether to run a full dnf upgrade before installing (will cause a reboot) |
nvidia_reboot_timeout |
300 |
Seconds to wait for host to come back after reboot |
nvidia_post_reboot_delay |
30 |
Seconds to wait after host is reachable before continuing |
- hosts: gpu_nodes
become: true
roles:
- nvidia_driver_cuda- hosts: gpu_nodes
become: true
roles:
- role: nvidia_driver_cuda
nvidia_module_stream: "550-dkms"
nvidia_driver_version: "550.127.05"- hosts: gpu_nodes
become: true
roles:
- role: nvidia_driver_cuda
nvidia_system_upgrade: false- Reboot to apply nvidia driver changes: triggered when nouveau is blacklisted or driver installed/updated
Handlers are flushed before the verification step, so nvidia-smi always runs against the freshly loaded driver.