Ubuntu auto-detect Nvidia driver version for install [duplicate]

I used this code to install the Nvidia driver:

sudo add-apt-repository ppa:graphics-drivers/ppa                
sudo apt update             
sudo apt install nvidia-384             

Problem: There are many versions available. How do I choose the right one? Is there any way to auto-detect the right version based on the hardware?


Solution 1:

Run

ubuntu-drivers devices

This should recommend the right driver.