Completely removing old Nvidia drivers

109,880

Solution 1

Pay your attention to ubuntu-drivers devices command output - there are following lines:

driver   : nvidia-340 - third-party free
driver   : nvidia-driver-390 - third-party free
driver   : nvidia-driver-396 - third-party free recommended
driver   : xserver-xorg-video-nouveau - distro free builtin

The lines mean you can use nvidia 340, 390, 396 drivers from third-party repository and open-source nouveau driver from distro repository. Only one driver is recommended to you. The list doesn't mean all of the mentioned drivers has been installed in your system. It indicates only potential possibility to install the drivers. The list can't be changed manually as being formed with ubuntu-drivers utility designed to automate proprietary drivers detecting, inspecting and installing from available to Ubuntu repositories.

Thus, to change the list it's necessary to remove third-party repository, which is proprietary GPU drivers repo in the particular case. But it's highly unrecommended to do, since your goal is to keep nvidia 396 driver anyway and remove from automatically created list nvidia 340 and 390 drivers. If you remove the third-party repository, only distro drivers will be detected as available, which will be in the particular case only 340 and 390 - thus, you'll obtain most undesired for you situation.

My suggestion for you is to do nothing. Your system looks healthy, everything works well.

If you like experiments, follow guide below.

The described below is for experimental purposes only - if you're not sure don't do it!

Press Ctrl+Alt+F4, log in and remove all of the nvidia staff:

sudo apt remove nvidia-*

Next remove proprietary PPA GPU drivers repository. Run in terminal:

sudo add-apt-repository --remove ppa:graphics-drivers/ppa
sudo apt update

Afterwards check available drivers in terminal:

ubuntu-drivers devices

You'll see the third-party nvidia drivers have dissapeared and only distro nvidia drivers are available. Among the drivers nvidia 396 will be absent since the driver isn't a part of Ubuntu distro repository.

Add your PPA proprietary GPU drivers repository back:

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update

Install your desired nvidia 396 again:

sudo ubuntu-drivers autoinstall

Reboot:

sudo reboot

After reboot, type nvidia-smi which will show different information about your graphic card like below:

xyz@xyz-workstation:~$ nvidia-smi
Mon Apr 27 12:41:50 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.64.00    Driver Version: 440.64.00    CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 166...  On   | 00000000:01:00.0 Off |                  N/A |
| N/A   45C    P8     1W /  N/A |    470MiB /  5944MiB |      5%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1905      G   /usr/lib/xorg/Xorg                            28MiB |
|    0      2058      G   /usr/bin/gnome-shell                          47MiB |
|    0      2956      G   /usr/lib/xorg/Xorg                           145MiB |
|    0      3133      G   /usr/bin/gnome-shell                         120MiB |
|    0      3587      G   ...AAAAAAAAAAAACAAAAAAAAAA= --shared-files   122MiB |
+-----------------------------------------------------------------------------+

For systems having nvidia-prime, if it returns an error then type sudo prime-select intel and then reboot and then type sudo prime-select nvidia and then reboot again. Now type nvidia-smi and it should work. This method works on most of the system with kernel till 5.4

Additionally see this my post.

Solution 2

  1. nvidia-installer --uninstall
  2. sudo apt remove nvidia-*
Share:
109,880

Related videos on Youtube

Eate
Author by

Eate

Updated on September 18, 2022

Comments

  • Eate
    Eate over 1 year

    I recently installed a fresh installation of Ubuntu, and downloaded some Nvidia drivers via nvidia-driver-390. I noticed that nvidia-340 was also installed (as a "binary driver" instead of a "driver metapackage"). Interesting. Later, I installed nvidia-driver-396. I'd like to remove versions 340 and 390, so I can only use 396. I have used sudo apt remove --purge nvidia-340 nvidia-390 and also uninstalled some of the related packages (nvidia-common, nvidia-current, nvidia-settings, nvidia-prime, nvidia-kernel-common*, etc.) At this point, I'm just trying to remove every trace of Nvidia drivers from my system and start fresh. Unfortunately, in the included "Software and Updates", drivers 340, 390, and 396 are still listed. A screenshot is attached. Thanks for your help.enter image description here

    ls -la /etc/apt/sources.list.d:

    total 44
    drwxr-xr-x 2 root root 4096 Jul 10 08:43 .
    drwxr-xr-x 6 root root 4096 May 20 12:58 ..
    -rw-r--r-- 1 root root  142 Jul 10 08:43 alexlarsson-ubuntu-flatpak-bionic.list
    -rw-r--r-- 1 root root  142 Jul 10 08:43 alexlarsson-ubuntu-flatpak-bionic.list.save
    -rw-r--r-- 1 root root   57 Jul 10 08:43 etcher.list
    -rw-r--r-- 1 root root   57 Jul 10 08:43 etcher.list.save
    -rw-r--r-- 1 root root  132 Jul 10 08:43 gezakovacs-ubuntu-ppa-bionic.list
    -rw-r--r-- 1 root root  132 Jul 10 08:43 gezakovacs-ubuntu-ppa-bionic.list.save
    -rw-r--r-- 1 root root  189 Jul 10 08:43 google-chrome-beta.list
    -rw-r--r-- 1 root root  189 Jul 10 08:43 google-chrome-beta.list.save
    -rw-r--r-- 1 root root  144 Jul 10 08:43 graphics-drivers-ubuntu-ppa-bionic.list
    

    Notes: So you have to remove the ppa to completely remove it?

    cat /etc/apt/sources.list:

    # deb cdrom:[Ubuntu 18.04 LTS _Bionic Beaver_ - Release amd64 (20180426)]/ bionic main restricted
    
    # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
    # newer versions of the distribution.
    deb http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
    # deb-src http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
    
    ## Major bug fix updates produced after the final release of the
    ## distribution.
    deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
    # deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
    
    ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
    ## team. Also, please note that software in universe WILL NOT receive any
    ## review or updates from the Ubuntu security team.
    deb http://us.archive.ubuntu.com/ubuntu/ bionic universe
    # deb-src http://us.archive.ubuntu.com/ubuntu/ bionic universe
    deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe
    # deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe
    
    ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
    ## team, and may not be under a free licence. Please satisfy yourself as to 
    ## your rights to use the software. Also, please note that software in 
    ## multiverse WILL NOT receive any review or updates from the Ubuntu
    ## security team.
    deb http://us.archive.ubuntu.com/ubuntu/ bionic multiverse
    # deb-src http://us.archive.ubuntu.com/ubuntu/ bionic multiverse
    deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
    # deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
    
    ## N.B. software from this repository may not have been tested as
    ## extensively as that contained in the main release, although it includes
    ## newer versions of some applications which may provide useful features.
    ## Also, please note that software in backports WILL NOT receive any review
    ## or updates from the Ubuntu security team.
    deb http://us.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
    # deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
    
    ## Uncomment the following two lines to add software from Canonical's
    ## 'partner' repository.
    ## This software is not part of Ubuntu, but is offered by Canonical and the
    ## respective vendors as a service to Ubuntu users.
    # deb http://archive.canonical.com/ubuntu bionic partner
    # deb-src http://archive.canonical.com/ubuntu bionic partner
    
    deb http://security.ubuntu.com/ubuntu bionic-security main restricted
    # deb-src http://security.ubuntu.com/ubuntu bionic-security main restricted
    deb http://security.ubuntu.com/ubuntu bionic-security universe
    # deb-src http://security.ubuntu.com/ubuntu bionic-security universe
    deb http://security.ubuntu.com/ubuntu bionic-security multiverse
    # deb-src http://security.ubuntu.com/ubuntu bionic-security multiverse
    deb http://us.archive.ubuntu.com/ubuntu/ bionic-proposed main universe restricted multiverse
    

    ubuntu-drivers devices:

    == /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
    modalias : pci:v000010DEd00001382sv000010DEsd00001065bc03sc00i00
    vendor   : NVIDIA Corporation
    model    : GM107 [GeForce GTX 745]
    driver   : nvidia-340 - third-party free
    driver   : nvidia-driver-390 - third-party free
    driver   : nvidia-driver-396 - third-party free recommended
    driver   : xserver-xorg-video-nouveau - distro free builtin
    
    == /sys/devices/pci0000:00/0000:00:1c.7/0000:04:00.0 ==
    modalias : pci:v000014E4d00004365sv00001028sd00000016bc02sc80i00
    vendor   : Broadcom Limited
    model    : BCM43142 802.11b/g/n (Wireless 1704 802.11n + BT 4.0)
    driver   : bcmwl-kernel-source - distro non-free
    

    Note: The second one is my wireless card, the first one is my graphics card that this is about.

    ubuntu-drivers list:

    nvidia-driver-390
    nvidia-340
    nvidia-driver-396
    bcmwl-kernel-source
    

    Note: Again, the first three are the ones I want to remove, and the last is for my wireless card.

  • Eate
    Eate almost 6 years
    I removed the ppa to see what would happen. It removed only version 396 (the one I want!)
  • Eate
    Eate almost 6 years
    Yes, thank you. I was a bit confused, but I now see how the ubuntu-drivers works (doesn't look at installed drivers, looks at all the installed and recommended drivers.
  • sam
    sam over 4 years
    it says command not found
  • sam
    sam over 4 years
    also follow this link in case of minor tweaks- forums.lenovo.com/t5/Gaming-Laptops-Knowledge-Base/…
  • Foreever
    Foreever about 4 years
    you can ignore the nvidia-installer if its says so ^. It works based on how you installed the nvidia driver.
  • sam
    sam about 4 years
    I figured out that this method works for those who have downloaded the graphics driver installer from nvidia's website.
  • sam
    sam about 4 years
    for others @Bob 's answer works.