First we will remove any pre-installed Nvidia driver or cuda versions. If you have a fresh installation of Ubuntu 18.04 then you don’t need to do this.
sudo apt-get purge nvidia* && sudo apt-get autoremove
sudo rm -rf /usr/local/cuda*
After performing this, do not restart the ubuntu as the nvidia driver is not installed and hence you might face difficulty in booting.
Now we will install the nvidia driver version 440.100(or higher). You can go to Ubuntu Software and Updates and install driver version 440.100(preferable) or use the following command to install the latest driver version available.
sudo ubuntu-drivers autoinstall
After the installation is done, reboot the system. After logging in, verify that the driver is correctly installed by executing the following:
nvidia-smi
#nvidia #lenovo-legion #ubuntu