I was using Ubuntu 16.04 LTS kernel 4.15.0-45 on Optimus-based laptops, and everything (CUDA + OpenGL display) went well.
I was using 960M with driver 396 in CUDA 9.2 at first, and recently updated to driver 418 with .run which also OK.
But kernel 4.15.0-45 has a xHCI controller bug which will cause xHCI controller dead randomly.
So I had to update the kernel.
When I finished to update to kernel 4.15.0-48, problem occurred.
If there was no xorg.conf, and I installed driver without OpenGL libraries, I could login but Nvidia graphic card was not used.
If there was no xorg.conf, and I installed driver with OpenGL libraries, the endless login problem occurred.
If I tried to use the xorg.conf which worked smoothly before, boot would stop at Ubuntu logo (loading page).
I have tried to install new driver 430 with .run, nothing changed.
Also I have tried to install driver from Ubuntu graphics ppa, still the same result.
(.run can select not to install OpenGL libraries, but nvidia-prime cannot run correctly.
ppa installer can not select OpenGL libraries, but nvidia-prime can do switch.)
The intel gpu kernel driver (i915) is missing, IIRC, it’s in the package linux-modules-extra, did the kernel update forget to install the matching package?
Try updating your system again, maybe it’s installed afterwards, otherwise install it manually.