Skip to content

Instantly share code, notes, and snippets.

@jacky9813
Created October 31, 2024 01:47
Show Gist options
  • Save jacky9813/694a837d93eb0812137665f083e42018 to your computer and use it in GitHub Desktop.
Save jacky9813/694a837d93eb0812137665f083e42018 to your computer and use it in GitHub Desktop.
Install NVIDIA proprietary driver on Fedora 41

There are some steps that is not documented in the RPMFusion's installation guide. Here's how I install NVIDIA driver on Fedora 41.

  1. Update all packages and reboot
  2. Install akmod-nvidia from RPMFusion, optionally with packages for CUDA or NVENC.
  3. For some reason, after akmod installation, I didn't see modeset=1 on kernel option, so:
#!/bin/bash
sudo grubby --update-kernel=ALL --args='nvidia-drm.modeset=1'
  1. Create file /etc/dracut.conf.d/nvidia.conf with the following content:
add_drivers+=" nvidia nvidia_modeset nvidia_uvm nvidia_drm "
install_items+=" /etc/modprobe.d/nvidia.conf "
  1. Create file /etc/modprobe.d/nvidia.conf with the following content:
options nvidia_drm modeset=1
  1. Wait until akmod done building the drivers.
  2. Rebuild initramfs sudo dracut --regenerate-all --force
  3. The system is ready to reboot.

TL;DR

The script has not been tested.

#!/bin/bash 
sudo dnf install akmod-nvidia \
    xorg-x11-drv-nvidia-cuda xorg-x11-drv-nvidia-cuda-libs \
    xorg-x11-drv-nvidia-power \
    nvidia-vaapi-driver libva-utils vdpauinfo

sudo grubby --update-kernel=ALL --args='nvidia-drm.modeset=1'


cat << EOF | sudo tee /etc/dracut.conf.d/nvidia.conf
add_drivers+=" nvidia nvidia_modeset nvidia_uvm nvidia_drm "
install_items+=" /etc/modprobe.d/nvidia.conf "
EOF

cat << EOF | sudo tee /etc/modprobe.d/nvidia.conf
options nvidia_drm modeset=1
EOF

while pgrep akmod; do
    sleep 5
done

sudo dracut --regenerate-all --force
@bitrot-alpha
Copy link

With driver series 570, DRM is enabled by default, no need for kernel parameter nvidia-drm.modeset=1.

This means followers of the guide above can skip steps 3 and 5. Additionally, the second line of the file created in step 4 (install_items+=) can also be ignored.

In step 7, if you have already rebooted after a kernel update, dracut may get an error because it can't find the NVIDIA kernel modules for the old kernel. Instead of running the command as given, you can generate a new initramfs for only the current running kernel with sudo dracut --force --kver $(uname -r) -M. I'm not sure if dracut will still replace the initramfs after it encounters an error, but probably not.

Updated Guide:

Don't skip any steps below!

  1. Update all packages and reboot (this is important because you need to be running latest kernel)
  2. Install akmod-nvidia from RPMFusion, optionally with packages for CUDA or NVENC.
  • CUDA: xorg-x11-drv-nvidia-cuda xorg-x11-drv-nvidia-cuda-libs
  • fix broken suspend: xorg-x11-drv-nvidia-power
  • VAAPI (hardware video decode) libraries: nvidia-vaapi-driver libva-utils vdpauinfo
  1. Create file /etc/dracut.conf.d/nvidia.conf with the following content:
add_drivers+=" nvidia nvidia_modeset nvidia_uvm nvidia_drm "
  1. Wait for akmod to finish building nvidia driver kernel modules.
  • to check: run top and see if akmods user/cc1 process is in the list
  • number of cc1 processes should match the number of threads your CPU has
  • akmod process runs faster on CPUs with more threads, on a 2012 quad core, the process takes about 5 minutes
    *** If you're superstitious, you can manually trigger akmod build process with sudo akmods --rebuild
  1. Rebuild initramfs for current kernel: sudo dracut --force --kver $(uname -r) -M
  2. Ready to reboot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment