Unable to switch back to the Nvidia proprietary driver after switching to the open source driver

Solution 1:

  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 command to install the correct proprietary Nvidia driver.

    sudo ubuntu-drivers autoinstall && sudo reboot  
    

    The autoinstall command of ubuntu-drivers installs drivers that are appropriate for automatic installation including their dependencies. This would normally include the nvidia-prime package (tools to enable NVIDIA's Prime). Then you will have an Nvidia X Server Settings icon in the Dash, and there in the left pane of Nvidia X Server Settings you can find PRIME profiles.