How do I get an external GPU with a hybrid laptop to output a display on Kubuntu? [duplicate]

I have this awkward issue,

Just made a fresh Ubuntu install (18.04), on my Dell XPS 9560, which I have an Intel GPU and a dedicated Nvidia 1050.

I also have an Akitio Node Pro Thunderbolt 3 eGPU with an Nvidia 1080 TI

I had issues with the nouveau driver which didn't let my laptop to go past the login screen - disabled.
Also had issues with the Official Nvidia Drivers which the pre-installation failed, and the fact that bumblebee didn't seem to work at all - nvidia-settings didn't start saying can't find drivers.

I now managed to remove everything and install the latest drivers via the CUDA 9.2 toolkit install.

nvidia-smi -L recognizes both GPUs (Internal 1050 and eGPU 1080 Ti)

eek@EEK-XPS:~$ nvidia-smi -L
GPU 0: GeForce GTX 1050 (UUID: GPU-bde2a9a0-4e30-5bb7-a131-95c438e827a2)
GPU 1: GeForce GTX 1080 Ti (UUID: GPU-d54c0a53-1d60-5f3d-399c-7e318b1de34f)

The question is, how can I make my external display which is connected to the 1080 Ti work?

Currently I either run it via Intel GPU (which runs at 4k) or via the 1050 GPU (which apparently supports just 1080p lol) but plugged into the 1080 Ti doesn't work at all.

I tried creating an xorg.conf

    Identifier      "Videocard0"
    BusID           "PCI:0b:00.0" # bus from lspci
    Driver          "nvidia"
    VendorName      "NVIDIA"
EndSection

The lspci output:

0b:00.0 VGA compatible controller: NVIDIA Corporation GP102 [GeForce GTX 1080 Ti] (rev a1)

I tried to change the PCI to just 0b:00.0 then PCI:0b:00.0, PCI:0b:00, PCI:00:0b:00, but none apparently work, don't really know how to add the bus there, since the bus is 0b:00 and function is .0

Any ideas what I can do to enable my external display to work via the connected eGPU? (On Windows it's just plug in and that's it).


I found an answer, and will post it here in case someone else also stumbles upon the same problem.

Ubuntu by default doesn't allow Display output via an ExternalGpu, hence this was the main issue (why the card was detected via nvidia-smi but Display didn't worked plugged to it).

I still have no idea why the NVIDIA X Server Settings wouldn't start - I now reinstalled everything and on Ubuntu 18.10 it works.

To get your external monitor to work via your eGPU on Ubuntu, you'll have to create a X11 config, aka create /etc/X11/xorg.conf.d/ and place an nvidia.conf there.

The config for /etc/X11/xorg.conf.d/nvidia.conf needs to look like this:

Section "Device"
        Identifier      "Videocard0"
        BusID           "PCI:11:0:0" # This must be what your lspci command gave you
        Driver          "nvidia"
        VendorName      "NVIDIA Corporation"
        Option          "AllowEmptyInitialConfiguration"
        Option          "AllowExternalGpus"
EndSection

The BusID needs to be in Decimal, hence why 0b, is 11, and it also needs 2 additional Options:

Option "AllowEmptyInitialConfiguration" - I have no idea why this is needed, but it would get stuck in a login loop without it.

and

Option "AllowExternalGpus" to allow Ubuntu to use the eGPU as a Display.