Installing Nvidia 450 graphics driver in Ubuntu 20.04

I run the following command

sudo apt install nvidia-driver-450

But it throws out an error with the following

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information msudo apt install nvidia-driver-450
sudo rebootay help to resolve the situation:

The following packages have unmet dependencies:
 nvidia-driver-450 : Depends: libnvidia-gl-450 (= 450.80.02-0ubuntu1) but 450.80.02-0ubuntu0.20.04.2 is to be installed
                     Depends: nvidia-dkms-450 (= 450.80.02-0ubuntu1)
                     Recommends: nvidia-settings but it is not going to be installed
                     Recommends: nvidia-prime (>= 0.8) but it is not installable
                     Recommends: libnvidia-compute-450:i386 (= 450.80.02-0ubuntu1)
                     Recommends: libnvidia-decode-450:i386 (= 450.80.02-0ubuntu1)
                     Recommends: libnvidia-encode-450:i386 (= 450.80.02-0ubuntu1)
                     Recommends: libnvidia-ifr1-450:i386 (= 450.80.02-0ubuntu1)
                     Recommends: libnvidia-fbc1-450:i386 (= 450.80.02-0ubuntu1)
                     Recommends: libnvidia-gl-450:i386 (= 450.80.02-0ubuntu1)
E: Unable to correct problems, you have held broken packages.

I also tried installing nvidia-prime but it said there's no installation candidate. I tried everything I found on askubuntu here and still couldn't solve it. Anything I missed out?


  1. Remove all the nvidia packages.

    sudo apt update
    sudo apt remove '^nvidia'
    sudo apt autoremove
    
  2. If you have added an Nvidia PPA to /etc/apt/sources.list remove that PPA by prefacing its line in sources.list with a # to comment it out. Run sudo apt update to refresh the list of available software.

  3. Reboot with sudo reboot

  4. Run the following commands to install the Nvidia 450 driver.

    sudo apt install nvidia-driver-450
    sudo reboot
    

After you have installed the nvidia-driver-450 graphics driver in Ubuntu 20.04 it may be updated from nvidia-driver-450 to nvidia-driver-460 by the normal software update activity.

As an alternative to step 4 you can let the ubuntu-drivers program automatically select the proprietary Nvidia packages that are most compatible with your GPU instead of guessing which Nvidia driver packages to install. To install the Nvidia proprietary driver this way run the following command instead of the commands in step 4.

sudo ubuntu-drivers autoinstall && sudo reboot

These steps are still working for nvidia-driver-470.