After upgrade Fedora, every now and then, the Nvdia drivers fail and it falls back to open source drivers. Which is both nice, and annoying. Its nice because you can still use your computer, its annoying because anything that requires Nvidia drivers won't work. I have in the past fixed this by removing and re-installing the drivers, but today I decided to deep dive and find a proper fix to the problem. Here is the solution that I'll be using from here on out.

  1. You can confirm the problem by running nvidia-smi:
    $ sudo 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.
  2. Rebuild the Nvidia kernel module:
    $ akmodsbuild /usr/src/akmods/nvidia-kmod.latest
    * Rebuilding /usr/src/akmods/nvidia-kmod.latest for kernel(s) 6.0.14-200.fc36.x86_64: prep build install clean; Successfull; Saved kmod-nvidia-6.0.14-200.fc36.x86_64-525.60.11-1.fc36.x86_64.rpm in /home/grmrgecko/
  3. Install the newly built kernel module:
$ sudo dnf reinstall kmod-nvidia-6.0.14-200.fc36.x86_64-525.60.11-1.fc36.x86_64.rpm
Last metadata expiration check: 1:17:09 ago on Sat 24 Dec 2022 07:36:36 PM CST.
Dependencies resolved.
========================================================================================================================================================================================================
 Package                                                         Architecture                        Version                                            Repository                                 Size
========================================================================================================================================================================================================
Reinstalling:
 kmod-nvidia-6.0.14-200.fc36.x86_64                              x86_64                              3:525.60.11-1.fc36                                 @commandline                               42 M

Transaction Summary
========================================================================================================================================================================================================

Total size: 42 M
Installed size: 42 M
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                1/1
  Reinstalling     : kmod-nvidia-6.0.14-200.fc36.x86_64-3:525.60.11-1.fc36.x86_64                                                                                                                   1/2
  Running scriptlet: kmod-nvidia-6.0.14-200.fc36.x86_64-3:525.60.11-1.fc36.x86_64                                                                                                                   1/2
  Cleanup          : kmod-nvidia-6.0.14-200.fc36.x86_64-3:525.60.11-1.fc36.x86_64                                                                                                                   2/2
  Running scriptlet: kmod-nvidia-6.0.14-200.fc36.x86_64-3:525.60.11-1.fc36.x86_64                                                                                                                   2/2
  Verifying        : kmod-nvidia-6.0.14-200.fc36.x86_64-3:525.60.11-1.fc36.x86_64                                                                                                                   1/2
  Verifying        : kmod-nvidia-6.0.14-200.fc36.x86_64-3:525.60.11-1.fc36.x86_64                                                                                                                   2/2

Reinstalled:
  kmod-nvidia-6.0.14-200.fc36.x86_64-3:525.60.11-1.fc36.x86_64

Complete!

That is it, once you reboot, it should be using the Nvidia drivers as you can confirm with nvidia-smi.

If you encounter the error below:

gcc: error: unrecognized command-line option '-ftrivial-auto-var-init=zero'

Check the GCC version and source, and if its version 11 or older, it may be from a package:

$ gcc --version
gcc (GCC) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ which gcc
/usr/lib64/ccache/gcc

In my case, it looks like it is from the ccache package, so just running sudo dnf remove ccache will fix the problem.

Previous Post Next Post