If you are planning to install Nvidia Drivers on Rocky Linux 8.5, you may want to use DNF to install. For a detailed explanation Streamlining NVIDIA Driver Deployment on RHEL 8 with Modularity Streams
Step 1: Add Offical Nvidia Repository to Package Managers repository list.
# dnf config-manager --add-repo=https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo
Step 2: Install Kernel-Devel and Headers used by the Drivers
# dnf install kernel-devel-$(uname -r) kernel-headers-$(uname -r)
Step 3: Installing Nvidia Drivers and Settings
# dnf install nvidia-driver nvidia-settings
Step 4: Install CUDA Drivers and REboot
# dnf install cuda-driver
Once done, do a reboot,
If after a reboot and if you do a “nvidia-smi” and receive an error like the one
# nvidia-smi NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.
You may want to take a look at https://gist.github.com/espoirMur/65cec3d67e0a96e270860c9c276ab9fa. It could be coming Secure Boot Option in your BIOS.