Ubuntu – How to use 2 displays with integrated graphics and Nvidia for cuda

18.04cuda

I've spent most of the last days trying to setup cuda on my PC. I own a MSI GE63VR with a Geforce 1070 which I desire to use for Machine Learning computing with cuda. My PC has a dualboot ubuntu 18.04 and windows 10.

My usual "work environnment" consists of my laptot along with an extra screen. I want to use the intel integrated graphics for display on both of my screens, and use my nvidia cards for cuda.

After many hours of trouble, I managed to install cuda and working nvidia drivers on my laptop. In order not to use the nvidia for display, I modified my xorg.conf file (located in /etc/X11) by following this tutorial instructions : https://gist.github.com/wangruohui/bc7b9f424e3d5deb0c0b8bba990b1bc5

My xorg.conf consists of :

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "intel"
    VendorName     "Intel Corporation"
    BusID          "PCI:0:2:0
EndSection

as suggested in the tutorial. This works just fine on my laptop screen(I can nvidia-smi and the 1070 is not used for display), but I can't use my extra screen. Nothing appears when I plug my hdmi cable. Do you know how to modify the xorg.conf to be able to use my extra screen?

I already used an intel integrated graphics for multi-screen display and nvidia for cuda on another laptop that was not setup by me. In that case, the prime profile of nvidia xserver config was the intel graphics, but you could still use nvidia-smi and use cuda. To achieve that, one would have to add :

PATH=$PATH:/usr/local/cuda-9.1/bin
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-9.1/lib64

to his .profile I tried that on my MSI, but I wasn't able to use nvidia-smi, and got the error :

NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver.
To sum it up, I want to be able to use my intel graphics for display on both my laptop screen and an extra monitor. My comprehension is that they are 2 ways to achieve that: -Use the nvidia as prime device, but modify the xorg.conf to be able to use 2 display with the intel graphics. -Use the intel as prime device, but do "something" to still be able to call nvidia-smi and use cuda.

Any help on either of those solutions would be greatly appreciated.

Edit : Since I posted this, I discovered that my HDMI port is on my nvidia. I changed my Xorg.conf to force the modesetting xorg driver to beloadead instead of the nvidia one for my GTX1070. When i do xrandr, I can see my HDMI connected, but when I do xrandr --output HDMI-1-1 --mode 1920x1080, I get the error : xrandr: Configure crtc 4 failed

Here's my new Xorg.conf:

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "intel"
    VendorName     "Intel Corporation"
    BusID          "PCI:0:2:0
EndSection

Section "Device"
    Identifier     "nvidia"
    Driver         "modesetting"
    BusID          "PCI:0:1:0"
EndSection

Here's the outpt of xrandr --listproviders:

Providers: number : 2
Provider 0: id: 0x89 cap: 0x9, Source Output, Sink Offload crtcs: 4 outputs: 2 associated providers: 1 name:Intel
Provider 1: id: 0x45 cap: 0x2, Sink Output crtcs: 4 outputs: 2 associated providers: 1 name:modesetting

And finally, here's the output of lspci:

00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v6/7th Gen Core Processor Host Bridge/DRAM Registers (rev 05)
00:01.0 PCI bridge: Intel Corporation Skylake PCIe Controller (x16) (rev 05)
00:02.0 VGA compatible controller: Intel Corporation Device 591b (rev 04)
00:14.0 USB controller: Intel Corporation Sunrise Point-H USB 3.0 xHCI Controller (rev 31)
00:14.2 Signal processing controller: Intel Corporation Sunrise Point-H Thermal subsystem (rev 31)
00:16.0 Communication controller: Intel Corporation Sunrise Point-H CSME HECI #1 (rev 31)
00:17.0 SATA controller: Intel Corporation Sunrise Point-H SATA Controller [AHCI mode] (rev 31)
00:1c.0 PCI bridge: Intel Corporation Sunrise Point-H PCI Express Root Port #1 (rev f1)
00:1c.4 PCI bridge: Intel Corporation Sunrise Point-H PCI Express Root Port #5 (rev f1)
00:1c.6 PCI bridge: Intel Corporation Sunrise Point-H PCI Express Root Port #7 (rev f1)
00:1c.7 PCI bridge: Intel Corporation Sunrise Point-H PCI Express Root Port #8 (rev f1)
00:1f.0 ISA bridge: Intel Corporation Sunrise Point-H LPC Controller (rev 31)
00:1f.2 Memory controller: Intel Corporation Sunrise Point-H PMC (rev 31)
00:1f.3 Audio device: Intel Corporation CM238 HD Audio Controller (rev 31)
00:1f.4 SMBus: Intel Corporation Sunrise Point-H SMBus (rev 31)
01:00.0 VGA compatible controller: NVIDIA Corporation GP104M [GeForce GTX 1070 Mobile] (rev a1)
02:00.0 Network controller: Qualcomm Atheros QCA6174 802.11ac Wireless Network Adapter (rev 32)
03:00.0 USB controller: ASMedia Technology Inc. ASM1142 USB 3.1 Host Controller
04:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS5250 PCI Express Card Reader (rev 01)
05:00.0 Ethernet controller: Qualcomm Atheros Killer E2500 Gigabit Ethernet Controller (rev 10)

Best Answer

In the meantime you've found out that the HDMI port is physically connected to the nVidia adapter only, so you have to choose:

  • Use CUDA and use the internal display only
  • Use the external display hooked up to the HDMI port and lose the CUDA ability.

As you have a laptop, adding (an) additional card(s) is impossible as a solution.

Note: According to your Laptop's Manual you also have a Mini Display Port, but according to the MSI forums, that's also connected to the nVidia, so that's not an option neither.

Related Question