Hybrid graphics (Quadro M2000M) boots garbled on Ubuntu 18.04

Hi all, I have a Lenovo P50 laptop with Quadro M2000M and Ubuntu 18.04 - it all works fine when I select “Discrete graphics” in BIOS. If I select “Hybrid graphics”, Ubuntu boots into a garbled mess - there are running lines on the screen but they are unreadable. It remotely resembles the boot sequence, but it never results in a usable image. After about 10 seconds, I see this:


I can’t get out to VT from here (Ctrl+Alt+F1), I can only reboot via Ctrl-Alt-Del. My setup is: latest BIOS v1.50, Ubuntu PPA drivers (nvidia-driver-390), Ubuntu 18.04 has all the latest updates. Also:

$ sudo lshw -C video
  *-display                 
       description: VGA compatible controller
       product: GM107GLM [Quadro M2000M]
       vendor: NVIDIA Corporation
       physical id: 0
       bus info: pci@0000:01:00.0
       version: a2
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress vga_controller bus_master cap_list rom
       configuration: driver=nvidia latency=0
       resources: irq:139 memory:b2000000-b2ffffff memory:a0000000-afffffff memory:b0000000-b1ffffff ioport:4000(size=128) memory:c0000-dffff

nouveau is blacklisted:

$ cat /etc/modprobe.d/nvidia-graphics-drivers.conf
blacklist nouveau
blacklist lbm-nouveau
alias nouveau off
alias lbm-nouveau off

Attached below is a nvidia-bug-report.sh output - but I had to do it after booting into “Discrete graphics” mode, as in the problematic “Hybrid graphics” mode the system cannot be interacted with other than Ctrl-Alt-Del.

I’m stuck. Any ideas?

nvidia-bug-report.log.gz (134 KB)

The log should be from when the issue is present. You could use ssh from another computer.
Nevertheless, you’re using the kernel parameter ‘nomodeset’
If you’re using that while on hybrid, things will break. Remove it.

That did it - I’m able to boot into hybrid graphics mode now. However when I switch to intel (sudo prime-select intel), it kicks me out into TTY - I’m then able to do startx and make it work. However on next reboot I’m stuck in TTY again, and this time startx won’t work. I attached nvidia-bug-report.sh output in that condition. Also of interest is Xorg.0.log after the startx failure:

[   158.715] 
X.Org X Server 1.19.6
Release Date: 2017-12-20
[   158.715] X Protocol Version 11, Revision 0
[   158.715] Build Operating System: Linux 4.4.0-119-generic x86_64 Ubuntu
[   158.715] Current Operating System: Linux porty4 4.15.0-22-generic #24-Ubuntu SMP Wed May 16 12:15:17 UTC 2018 x86_64
[   158.715] Kernel command line: BOOT_IMAGE=/vmlinuz-4.15.0-22-generic root=/dev/mapper/ubuntu--vg-root ro acpi_backlight=vendor
[   158.715] Build Date: 13 April 2018  08:07:36PM
[   158.715] xorg-server 2:1.19.6-1ubuntu4 (For technical support please see http://www.ubuntu.com/support) 
[   158.715] Current version of pixman: 0.34.0
[   158.715] 	Before reporting problems, check http://wiki.x.org
	to make sure that you have the latest version.
[   158.715] Markers: (--) probed, (**) from config file, (==) default setting,
	(++) from command line, (!!) notice, (II) informational,
	(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
[   158.715] (==) Log file: "/home/arkamax/.local/share/xorg/Xorg.0.log", Time: Tue Jun  5 10:52:22 2018
[   158.715] (==) Using system config directory "/usr/share/X11/xorg.conf.d"
[   158.716] (==) No Layout section.  Using the first Screen section.
[   158.716] (==) No screen section available. Using defaults.
[   158.716] (**) |-->Screen "Default Screen Section" (0)
[   158.716] (**) |   |-->Monitor "<default monitor>"
[   158.716] (==) No device specified for screen "Default Screen Section".
	Using the first device section listed.
[   158.716] (**) |   |-->Device "Intel Graphics"
[   158.716] (==) No monitor specified for screen "Default Screen Section".
	Using a default monitor configuration.
[   158.716] (==) Automatically adding devices
[   158.716] (==) Automatically enabling devices
[   158.716] (==) Automatically adding GPU devices
[   158.716] (==) Automatically binding GPU devices
[   158.716] (==) Max clients allowed: 256, resource mask: 0x1fffff
[   158.716] (WW) The directory "/usr/share/fonts/X11/cyrillic" does not exist.
[   158.716] 	Entry deleted from font path.
[   158.716] (WW) The directory "/usr/share/fonts/X11/100dpi/" does not exist.
[   158.716] 	Entry deleted from font path.
[   158.716] (WW) The directory "/usr/share/fonts/X11/75dpi/" does not exist.
[   158.716] 	Entry deleted from font path.
[   158.716] (WW) The directory "/usr/share/fonts/X11/100dpi" does not exist.
[   158.716] 	Entry deleted from font path.
[   158.716] (WW) The directory "/usr/share/fonts/X11/75dpi" does not exist.
[   158.716] 	Entry deleted from font path.
[   158.716] (==) FontPath set to:
	/usr/share/fonts/X11/misc,
	/usr/share/fonts/X11/Type1,
	built-ins
[   158.716] (==) ModulePath set to "/usr/lib/xorg/modules"
[   158.716] (II) The server relies on udev to provide the list of input devices.
	If no devices become available, reconfigure udev or disable AutoAddDevices.
[   158.716] (II) Loader magic: 0x55c6f2313020
[   158.716] (II) Module ABI versions:
[   158.716] 	X.Org ANSI C Emulation: 0.4
[   158.716] 	X.Org Video Driver: 23.0
[   158.716] 	X.Org XInput driver : 24.1
[   158.716] 	X.Org Server Extension : 10.0
[   158.717] (++) using VT number 2

[   158.718] (II) systemd-logind: took control of session /org/freedesktop/login1/session/_33
[   158.719] (II) xfree86: Adding drm device (/dev/dri/card0)
[   158.719] (II) systemd-logind: got fd for /dev/dri/card0 226:0 fd 11 paused 0
[   158.719] (II) xfree86: Adding drm device (/dev/dri/card1)
[   158.720] (II) systemd-logind: got fd for /dev/dri/card1 226:1 fd 12 paused 0
[   158.720] (**) OutputClass "nvidia" ModulePath extended to "/usr/lib/x86_64-linux-gnu/nvidia/xorg,/usr/lib/xorg/modules"
[   158.720] (**) OutputClass "Nvidia Prime" ModulePath extended to "/x86_64-linux-gnu/nvidia/xorg,/usr/lib/x86_64-linux-gnu/nvidia/xorg,/usr/lib/xorg/modules"
[   158.720] (**) OutputClass "Nvidia Prime" setting /dev/dri/card0 as PrimaryGPU
[   158.721] (--) PCI: (0:0:2:0) 8086:191d:17aa:222e rev 6, Mem @ 0xd2000000/16777216, 0x60000000/536870912, I/O @ 0x00005000/64, BIOS @ 0x????????/131072
[   158.721] (--) PCI:*(0:1:0:0) 10de:13b0:17aa:222e rev 162, Mem @ 0xd3000000/16777216, 0xc0000000/268435456, 0xd0000000/33554432, I/O @ 0x00004000/128, BIOS @ 0x????????/524288
[   158.721] (II) LoadModule: "glx"
[   158.721] (II) Loading /usr/lib/x86_64-linux-gnu/nvidia/xorg/libglx.so
[   158.724] (II) Module glx: vendor="NVIDIA Corporation"
[   158.724] 	compiled for 4.0.2, module version = 1.0.0
[   158.724] 	Module class: X.Org Server Extension
[   158.724] (II) NVIDIA GLX Module  390.48  Wed Mar 21 23:42:56 PDT 2018
[   158.724] (II) LoadModule: "intel"
[   158.724] (II) Loading /usr/lib/xorg/modules/drivers/intel_drv.so
[   158.724] (II) Module intel: vendor="X.Org Foundation"
[   158.724] 	compiled for 1.19.5, module version = 2.99.917
[   158.724] 	Module class: X.Org Video Driver
[   158.724] 	ABI class: X.Org Video Driver, version 23.0
[   158.724] (II) intel: Driver for Intel(R) Integrated Graphics Chipsets:
	i810, i810-dc100, i810e, i815, i830M, 845G, 854, 852GM/855GM, 865G,
	915G, E7221 (i915), 915GM, 945G, 945GM, 945GME, Pineview GM,
	Pineview G, 965G, G35, 965Q, 946GZ, 965GM, 965GME/GLE, G33, Q35, Q33,
	GM45, 4 Series, G45/G43, Q45/Q43, G41, B43
[   158.725] (II) intel: Driver for Intel(R) HD Graphics
[   158.725] (II) intel: Driver for Intel(R) Iris(TM) Graphics
[   158.725] (II) intel: Driver for Intel(R) Iris(TM) Pro Graphics
[   158.725] xf86EnableIOPorts: failed to set IOPL for I/O (Operation not permitted)
[   158.725] (II) intel(G0): Using Kernel Mode Setting driver: i915, version 1.6.0 20171023
[   158.725] (II) intel(G0): SNA compiled: xserver-xorg-video-intel 2:2.99.917+git20171229-1 (Timo Aaltonen <tjaalton@debian.org>)
[   158.725] (II) intel(G0): SNA compiled for use with valgrind
[   158.745] (EE) No devices detected.
[   158.745] (II) Applying OutputClass "nvidia" to /dev/dri/card0
[   158.745] 	loading driver: nvidia
[   158.745] (II) Applying OutputClass "Nvidia Prime" to /dev/dri/card0
[   158.745] 	loading driver: nvidia
[   158.745] (==) Matched nvidia as autoconfigured driver 0
[   158.745] (==) Matched nvidia as autoconfigured driver 1
[   158.745] (==) Matched nouveau as autoconfigured driver 2
[   158.745] (==) Matched nouveau as autoconfigured driver 3
[   158.745] (==) Matched modesetting as autoconfigured driver 4
[   158.745] (==) Matched fbdev as autoconfigured driver 5
[   158.745] (==) Matched vesa as autoconfigured driver 6
[   158.745] (==) Assigned the driver to the xf86ConfigLayout
[   158.745] (II) LoadModule: "nvidia"
[   158.745] (II) Loading /usr/lib/x86_64-linux-gnu/nvidia/xorg/nvidia_drv.so
[   158.746] (II) Module nvidia: vendor="NVIDIA Corporation"
[   158.746] 	compiled for 4.0.2, module version = 1.0.0
[   158.746] 	Module class: X.Org Video Driver
[   158.746] (II) LoadModule: "nouveau"
[   158.746] (II) Loading /usr/lib/xorg/modules/drivers/nouveau_drv.so
[   158.747] (II) Module nouveau: vendor="X.Org Foundation"
[   158.747] 	compiled for 1.19.3, module version = 1.0.15
[   158.747] 	Module class: X.Org Video Driver
[   158.747] 	ABI class: X.Org Video Driver, version 23.0
[   158.747] (II) LoadModule: "modesetting"
[   158.747] (II) Loading /usr/lib/xorg/modules/drivers/modesetting_drv.so
[   158.747] (II) Module modesetting: vendor="X.Org Foundation"
[   158.747] 	compiled for 1.19.6, module version = 1.19.6
[   158.747] 	Module class: X.Org Video Driver
[   158.747] 	ABI class: X.Org Video Driver, version 23.0
[   158.747] (II) LoadModule: "fbdev"
[   158.747] (II) Loading /usr/lib/xorg/modules/drivers/fbdev_drv.so
[   158.748] (II) Module fbdev: vendor="X.Org Foundation"
[   158.748] 	compiled for 1.19.3, module version = 0.4.4
[   158.748] 	Module class: X.Org Video Driver
[   158.748] 	ABI class: X.Org Video Driver, version 23.0
[   158.748] (II) LoadModule: "vesa"
[   158.748] (II) Loading /usr/lib/xorg/modules/drivers/vesa_drv.so
[   158.748] (II) Module vesa: vendor="X.Org Foundation"
[   158.748] 	compiled for 1.19.3, module version = 2.3.4
[   158.748] 	Module class: X.Org Video Driver
[   158.748] 	ABI class: X.Org Video Driver, version 23.0
[   158.748] (II) intel: Driver for Intel(R) Integrated Graphics Chipsets:
	i810, i810-dc100, i810e, i815, i830M, 845G, 854, 852GM/855GM, 865G,
	915G, E7221 (i915), 915GM, 945G, 945GM, 945GME, Pineview GM,
	Pineview G, 965G, G35, 965Q, 946GZ, 965GM, 965GME/GLE, G33, Q35, Q33,
	GM45, 4 Series, G45/G43, Q45/Q43, G41, B43
[   158.749] (II) intel: Driver for Intel(R) HD Graphics
[   158.749] (II) intel: Driver for Intel(R) Iris(TM) Graphics
[   158.749] (II) intel: Driver for Intel(R) Iris(TM) Pro Graphics
[   158.749] (II) NVIDIA dlloader X Driver  390.48  Wed Mar 21 23:18:15 PDT 2018
[   158.749] (II) NVIDIA Unified Driver for all Supported NVIDIA GPUs
[   158.749] (II) NOUVEAU driver Date:   Fri Apr 21 14:41:17 2017 -0400
[   158.749] (II) NOUVEAU driver for NVIDIA chipset families :
[   158.749] 	RIVA TNT        (NV04)
[   158.749] 	RIVA TNT2       (NV05)
[   158.749] 	GeForce 256     (NV10)
[   158.749] 	GeForce 2       (NV11, NV15)
[   158.749] 	GeForce 4MX     (NV17, NV18)
[   158.749] 	GeForce 3       (NV20)
[   158.749] 	GeForce 4Ti     (NV25, NV28)
[   158.749] 	GeForce FX      (NV3x)
[   158.749] 	GeForce 6       (NV4x)
[   158.749] 	GeForce 7       (G7x)
[   158.749] 	GeForce 8       (G8x)
[   158.749] 	GeForce GTX 200 (NVA0)
[   158.749] 	GeForce GTX 400 (NVC0)
[   158.749] (II) modesetting: Driver for Modesetting Kernel Drivers: kms
[   158.749] (II) FBDEV: driver for framebuffer: fbdev
[   158.749] (II) VESA: driver for VESA chipsets: vesa
[   158.749] xf86EnableIOPorts: failed to set IOPL for I/O (Operation not permitted)
[   158.750] (WW) Falling back to old probe method for modesetting
[   158.750] (WW) Falling back to old probe method for fbdev
[   158.750] (WW) Falling back to old probe method for vesa
[   158.750] (WW) Falling back to old probe method for modesetting
[   158.750] (WW) Falling back to old probe method for fbdev
[   158.750] (WW) Falling back to old probe method for vesa
[   158.750] (II) systemd-logind: releasing fd for 226:0
[   158.815] (EE) [drm] Failed to open DRM device for (null): -2
[   158.839] (II) modeset(G1): using drv /dev/dri/card0
[   158.839] (EE) No devices detected.
[   158.839] (EE) 
Fatal server error:
[   158.839] (EE) no screens found(EE) 
[   158.839] (EE) 
Please consult the The X.Org Foundation support 
	 at http://wiki.x.org
 for help. 
[   158.839] (EE) Please also check the log file at "/home/arkamax/.local/share/xorg/Xorg.0.log" for additional information.
[   158.839] (EE) 
[   158.854] (EE) Server terminated with error (1). Closing log file.

Looks like nouveau driver is loaded - but I’m fairly positive it was blacklisted:

$ cat /etc/modprobe.d/nvidia-graphics-drivers.conf 
blacklist nouveau
blacklist lbm-nouveau
alias nouveau off
alias lbm-nouveau off

There are also a few entries of “xf86EnableIOPorts: failed to set IOPL for I/O (Operation not permitted)” - not sure what this refers to.

If I do sudo prime-select nvidia at that time, I can “startx”, but it’s stuck at login prompt loop. Rebooting brings things back to normal, but I’m not using Intel card at that point.

I’m almost there :|
nvidia-bug-report.log.gz (121 KB)

Prime-select has been changed in Ubuntu 18.04, it now requires a full reboot and then loads the nouveau driver instead of bbswitch to turn off the nvidia gpu. So what you see is intended. Downside is, apart from the reboot, it’s not working sometimes depending on hardware like on yours.
See this thread about the issue and reverting to the previous behaviour:
[url]https://devtalk.nvidia.com/default/topic/1032482/linux/optimus-on-ubuntu-18-04-is-a-step-backwards-but-i-found-the-first-good-solution/[/url]

Actually I tried that solution to no avail - it results in the same behavior (where I’m forced out of X session), and reboot tries to load nouveau. I will ask in that thread then, thanks for your help!