Trouble removing NVIDIA drivers

Solution 1:

List all Nvidia related packages

dpkg -l | grep nvidia

Purge all the Nvidia related package you see in the list

When you have done this successfully

sudo ubuntu-drivers autoinstall
sudo prime-select nvidia

Reboot and now your system should work fine

Solution 2:

I had similar problem. Exact steps might be different but you should get an idea from what I did.

  1. uninstall nvidia drivers as mentioned above.

  2. reboot and instead of login to UI, login to console

  3. make sure nvidia modules are not loaded. You can do that by running command

sudo lsmod  | grep nvidia

This will list any nvidia modules loaded by the kernel. If the modules are loaded that means your nvidia uninstall was not clean and you will need to manually remove the kernel module.

rmmod <name of nvidia modules>
  1. Install xserver-xorg
sudo apt-get install --reinstall xserver-xorg-video-nouveau

This will set your system to use nouveau.

  1. Reboot and connect your monitor. It should detect now.

  2. Use "Additional Drivers" from "Show Application" to install nvidia drivers. (I think latest right now is "nvidia driver metapackage from nvidia-driver-470".

Reboot.

  1. Assuming you don't have secure boot enabled. If secure boot is enable you need to ensure that nvidia kernel modules are signed and loaded.

  2. run sudo lsmod | grep nvidia and nvidia-smi to check if nvidia drivers are loaded.

  3. Now run torch.cuda.is_available() and see if it is able to use GPU.