Reboot your PC.
At the login screen, do not login to any account, press Crt-Alt-F1
Login with your user account
pgrep dm -l
look for process ‘begin with dm’
issue a kill command to stop the dm process (x server)
sudo kill 2654
This will exit you from the session.
Log back in with the same account you used earlier.
Now you should be able to proceed as normal with the NVIDIA installation.