I’m also running Ubuntu 18.04 in a similar dual setup with an Intel onboard GPU. I tried a bunch of options to make the Intel gfx card the primary one in order to maximize GPU memory in the Nvidia card. When using the apt-get
based driver installation, you will have to blacklist the nvidia-drm driver in /etc/modprobe.d/blacklist-nvidia.conf
and also remove the nvidia card from /etc/X11/xorg.conf
as explained in the link above. All in all it felt like a very brittle operation to make my Ubuntu use the Intel card.
After lots of experimenting, the best option I found was to install the Nvidia driver from http://us.download.nvidia.com/XFree86/Linux-x86/396.24/README/installdriver.html
The important step is to disable installation of any X Server support:
sudo sh NVIDIA-Linux-x86_64-396.24.run --no-opengl-files --dkms --no-drm
This is fine for me since I don’t want any GUI running on the NVidia card but instead purely use it for Cuda processing.