Linux Housekeeping: Downgrading Nvidia Drivers to Fix Kernel Panic in Arch Linux

2024-05-13

Recently, I encountered an issue with my Arch Linux system randomly freezing, along with the caps lock key blinking during the freeze. Further research 1 2 revealed that the culprit was Nvidia (of course!) and their current 550 drivers causing random kernel panics.

In this blog, I’ll outline how to downgrade Nvidia drivers to 545 version, which currently serves as the potential fix for the issue. This blog is also relevant in scenarios where you would want to downgrade any other packages.

Let’s begin:

Note: Downgrading packages should be your last resort for fixing things as you miss out on bug fixes or security updates from the newer versions which may be important.

Installing Downgrade

We will be using downgrade for the procedure. It is a shell script aimed at automating the multi-step process mentioned in the Arch wiki, it also let’s you manage versions for packages easily.

Install downgrade from AUR:

$ yay -S downgrade

Downgrading regular packages

Downgrading a package using this tool is simple:

# downgrade <package-name>

This treats you with a fzf TUI to select a specific version, after which pacman prompts you with further required steps for the downgrade.

Downgrading Nvidia Packages

Note: It’s highly recommended to make a backup using tools like timeshift before proceeding further, as downgrading the kernel and graphics drivers can make your system unusable and loss of data. DON’T proceed without it.

Nvidia drivers are compiled according to a specific kernel version, because of this, we also need to downgrade the kernel packages to the version required by the Nvidia package.

Specifically you would need to deal with the following packages:

  • For kernel downgrade
    • linux
    • linux-headers
  • For Nvidia downgrade
    • nvidia
    • nvidia-utils

Determining package version

Next steps involve determining the specific version of these packages that would work with the Nvidia 545 package:

  • Go to the Arch linux’s nvidia gitlab repo and click on the history menu which shows the commit history, (nvidia-lts if you are using the lts packages)
  • In the branch menu, search for the specific version/tag of Nvidia package you want to use, I will use the version 545.29.06-20, as it was the top result when I typed 545.

You will see several commits, choose one containing the linux kernel version as shown in the red box below

Arch linux Nvidia package page

With the information from the commit message you have the required driver and kernel version, repeat the same procedure for determining the versions for all the other packages as well.

Downgrading

Query the specific versions you got to the downgrade command as shown below.

# downgrade 'linux=6.7.6.arch1-1' 'linux-headers=6.7.6.arch1-1' 'nvidia=545.29.06-20' 'nvidia-utils=545.29.06-4'

To do this interactively, simply run

# downgrade linux linux-headers nvidia nvidia-utils

And choose the specific versions from the fzf menu.

The downgrade process starts, wait for the process to run, you will be prompted with pacman prompts, which should be easy to navigate.

After the process completes perform a reboot:

$ reboot

After your machine boots up, check if the downgrade was successful by running:

$ nvidia-smi

Output from running nvidia-smi command

You can see the nvidia driver version successfully downgraded to 545, which was our desired outcome.

Ref: Arch Wiki