My laptop runs Ubuntu 18.04 and is equipped with both integrated Intel and dedicated NVIDIA GPU, using Optimus technology. I was using nvidia-340 driver, installed from apt.
I needed CUDA, so I can run tensorflow code on GPU, so first I needed to upgrade my driver. I downloaded legacy 390 driver from official site and installed it, it appeared to work fine. Then I proceeded to install CUDA 9, but for some reason examples wouldn't run so I knew something was wrong.
After rebooting Ubuntu started to freeze immediately after I login. Desktop icons, background don't load, can't move mouse pointer.
Purging NVIDIA drivers and installing 340 again doesn't help. In that case, when I boot it gets stuck on that black screen with items ticked with green "[OK]"s. It seems to freeze upon starting gnome.
I tried "nomodeset" and various "acpi_os" options in GRUB. Doesn't help.
Best thing I could achieve was purging all NVIDIA drivers again (driver defaults to nouveau). Then I boot up, login, get to Desktop and can use everything, but resolution is ridiculous: 960x540. There's only one alternative (an even worse resolution).
After having viewed lots of askubuntu questions and YouTube videos today I still have no idea what could I do next. Please help.