Create the file /etc/modprobe.d/nvidia-modeset.conf
.
Add setting options nvidia_drm modeset=1
inside the file.
Then sudo update-initramfs -u
in the terminal.
Restart.
This generates some input lag, but seems comparable to the default Intel setting with the integrated graphics.
Games play fine (e.g. FPS games).
Tested with Kubuntu 18.04, nvidia-390 drivers, Nvidia 960M card on an ASUS ROG laptop.
You may have quirks depending on your hardware vendor. The only one I'm seeing is desktop icons look weird after waking from suspend. Select all and drag with mouse and they get back to normal.
According to comments in this thread: https://devtalk.nvidia.com/default/topic/1032482/linux/optimus-on-ubuntu-18-04-is-a-step-backwards-but-i-found-the-first-good-solution/2
Modeset=1 enables prime sync which only helps for tearing on displays connected to the Intel card. Tearing on any other screen is an NVIDIA problem. Try enabling pipeline composition (via nvidia-settings GUI for instance)