How to Install NVIDIA Driver and CUDA on Rocky 9.1

I actually found instructions that seem to be working, without having to disable Secure Boot:

https://www.reddit.com/r/RockyLinux/comments/woqgij/rocky_9_nvidia_drivers_secure_boot_success/

I changed the instructions a bit, e.g. the non-working “sudo echo >” commands in the original instructions:

sudo dnf install epel-release 
sudo dnf upgrade
sudo reboot

After the reboot:

sudo dnf config-manager --add-repo http://developer.download.nvidia.com/compute/cuda/repos/rhel9/$(uname -i)/cuda-rhel9.repo
sudo dnf install kernel-headers-$(uname -r) kernel-devel-$(uname -r) tar bzip2 make automake gcc gcc-c++ pciutils elfutils-libelf-devel libglvnd-opengl libglvnd-glx libglvnd-devel acpid pkgconfig dkms
sudo dnf module install nvidia-driver:latest-dkms
echo "blacklist nouveau" | sudo tee /etc/modprobe.d/blacklist-nouveau.conf
echo 'omit_drivers+=" nouveau "' | sudo tee /etc/dracut.conf.d/blacklist-nouveau.conf
sudo dracut --regenerate-all --force
sudo depmod -a

The mokutil command will prompt for you to make up a password, which will be used during reboot

sudo mokutil --import /var/lib/dkms/mok.pub
sudo reboot

After the reboot, your system should ask you if you want to enroll a key or something like that, say yes and it asks for the password you gave in the mokutil command.

Later on, check that the nvidia drivers are installed:

nvidia-smi

If you dual boot windows, a windows-driven firmware update may reset the TPM chip (?). Anyway, any time this happens you’ll need to re-run ‘mokutil --import /var/lib/dkms/mok.pub’

3 Likes