display on intel, cuda on nvidia, Dell Inspiron 7000

dear all, I can really do with some input … here is my problem:

  • I have a Dell Inspiron 15 7000 with both a GTX 1060 and an intel graphic card
  • ubuntu 18.04
  • cuda V9.1.85

I would lkike to run the graphics on intel and run cuda on the GTX.

with prime-select I can switch between intel and nvidia just fine. when I use nvidia for the xserver
the kernel modules are loaded and I can use cuda perfectly fine, too. however, with nvidia the laptop power management is a dogs breakfast (graphic scrambled after suspend, laptop must be plugged in etc) …

now, I realized that I can

a.) prime-select intel
b.) reboot
c.) nvidia-smi tells me that it can not find the required modules.
d.) load manually with modprobe the mods nvidia, nvidia_modeset, nvidia_drm and nvidias_uvm.
e.) nvidia-smi then gives me the expected and correct output
f.) cuda and the machine learning stuff I am developing works then perfectly fine.
g.) however, after some time the xserver gets “messed up” and just shuts down. I guess there is some sort of refresh where the xserver gets confused which modules it is supposed to use as both the intel and the nvidia mods are loaded. note, that I could not find much in the xserver log files.

would anyone know how to configure the xserver s.t. this does not happen anymore? overall, I would like to
a.) run intel
b.) load/unload the nvidia mods if I need to work with cuda
c.) and not have the xserver crash on me every 20 mins or so while the nvidia modules are loaded.

thanks, aki

ps: previously, I did things like outlined here https://devtalk.nvidia.com/default/topic/991849/-solved-run-cuda-on-dedicated-nvidia-gpu-while-connecting-monitors-to-intel-hd-graphics-is-this-possible-/