Ubuntu 18.04 Can't see second monitor

I recently updated to 18.04 . My laptop has an Optimus configuration so both Nvidia and Intel cards. I could not get past the login screen of Gnome using Xorg. The mouse and screen would freeze. I found that by deleting xorg.conf that I could then login. If I tried generating an xorg.conf file with nvidia-xconfig . This xorg.conf file would again freeze my login attempts soI would again delete the xorg.conf file. My problem is that nvidia-settings and Gnome settings now do not see a second attached monitor. Xorg is using the the files in /usr/share/X11/xorg.conf.d/ to load. Below is my gpu-manager.log file .

last_boot_file: /var/lib/ubuntu-drivers-common/last_gfx_boot
    new_boot_file: /var/lib/ubuntu-drivers-common/last_gfx_boot
    can't access /opt/amdgpu-pro/bin/amdgpu-pro-px
    Looking for nvidia modules in /lib/modules/4.15.0-22-generic/updates/dkms
    Found nvidia module: nvidia-modeset.ko
    Looking for amdgpu modules in /lib/modules/4.15.0-22-generic/updates/dkms
    Is nvidia loaded? yes
    Was nvidia unloaded? no
    Is nvidia blacklisted? no
    Is intel loaded? yes
    Is radeon loaded? no
    Is radeon blacklisted? no
    Is amdgpu loaded? no
    Is amdgpu blacklisted? no
    Is amdgpu versioned? no
    Is amdgpu pro stack? no
    Is nouveau loaded? no
    Is nouveau blacklisted? yes
    Is nvidia kernel module available? yes
    Is amdgpu kernel module available? no
    Vendor/Device Id: 8086:591b
    BusID "PCI:0@0:2:0"
    Is boot vga? yes
    Vendor/Device Id: 10de:1c20
    BusID "PCI:1@0:0:0"
    Is boot vga? no
    Skipping "/dev/dri/card0", driven by "i915"
    Skipping "/dev/dri/card1", driven by "nvidia-drm"
    Skipping "/dev/dri/card0", driven by "i915"
    Skipping "/dev/dri/card1", driven by "nvidia-drm"
    Skipping "/dev/dri/card0", driven by "i915"
    Skipping "/dev/dri/card1", driven by "nvidia-drm"
    Found "/dev/dri/card0", driven by "i915"
    output 0:
    Number of connected outputs for /dev/dri/card0: 1
    Does it require offloading? yes
    last cards number = 2
    Has amd? no
    Has intel? yes
    Has nvidia? yes
    How many cards? 2
    Has the system changed? No
    Intel IGP detected
    Intel hybrid system
    Nvidia driver version 396.24 detected
    Creating /usr/share/X11/xorg.conf.d/11-nvidia-prime.conf

Any ideas how to fix this so nvidia sees a second monitor?
nvidia-bug-report.log.gz (103 KB)

Optimus is currently kind of broken with ubuntu 18.04. You could delete the xorg.conf and run sudo prime-select nvidia to try getting it back on track. Otherwise, please run nvidia-bug-report.sh as root and attach the resulting .gz file to your post. Hovering the mouse over an existing post will reveal a paperclip icon.

Thanks generix. I had tried prime-select and unfortunately didn’t help. I added the bug report above . I hope it worked ok. Please let me know if it shows anything useful that will get me up and running with a second monitor.

nvidia-bug-report.log (835 KB)
xsession.log (75.3 KB)

Now that’s a mess. The dmesg is flooded by errors from your touchpad and no current Xorg log is included, so I can’t see what’s currently running.
But the gpumanager generated config is wrong, it sets the wrong ModulePath, this can’t work. This should be reported to Ubuntu

*** /usr/share/X11/xorg.conf.d/11-nvidia-prime.conf
*** ls: -rw-r--r-- 1 root root 329 2018-05-23 11:15:22.324865818 -0400 /usr/share/X11/xorg.conf.d/11-nvidia-prime.conf

Section "OutputClass"
    Identifier "Nvidia Prime"
    MatchDriver "nvidia-drm"
    Driver "nvidia"
    Option "AllowEmptyInitialConfiguration"
    Option "IgnoreDisplayDevices" "CRT"
    Option "PrimaryGPU" "Yes"
    ModulePath "/x86_64-linux-gnu/nvidia/xorg"

Best action would be downgrade back to 17.10 or 16.04 and wait until they fix that.
Otherwise, you could try to manually override:

  • add kernel parameter
  • delete /usr/share/X11/xorg.conf.d/11-nvidia-prime.conf
  • edit /usr/share/X11/xorg.conf.d/10-nvidia.conf
    Option “PrimaryGPU” “Yes”
    into the outputclass section
  • reboot
  • check if the file /usr/share/X11/xorg.conf.d/11-nvidia-prime.conf is really gone.
  • create another nvidia-bug-report.log
  • also run sudo journalctl -b 0 --no-pager _COMM=gdm-x-session >xsession.log
    and attach that.

Thanks again generix. I can confirm that /usr/share/X11/xorg.conf.d/11-nvidia-prime.conf does not reappear after booting with nogpumanager as a kernel parameter. I have attached the new bug report and session.log to my previous comment. I added Option “PrimaryGPU” “Yes” to /usr/share/X11/xorg.conf.d/10-nvidia.conf . After doing as you suggested unfortunately I still can’t see a second monitor attached to my HDMI port. If I use Intel as selected using nvidia-settings I do see a second monitor . Still hoping I can get it to work using the nvidia card without having to downgrading Ubuntu.

xsession.log (75.6 KB)

Messy. The new nvidia-bug-report was the old one, you forgot to delete it prior to re-running the script, the new one probably has a different name. Doesn’t matter though, the xsession.log contains the necessary info.
It shows two bugs which should be reported to Ubuntu as well.
#1 glamoregl gets loaded while it shouldn’t, it’s keeping prime from working properly.
#2 the nvidia driver doesn’t probe for any outputs, that’s why your external monitor doesn’t work. I don’t know if that’s a side effect of #1 or a general driver bug.

The first one can be worked around by extending the config but this would keep xorg from working when switched to intel.
Create a new file /etc/X11/xorg.conf.d/20-prime-intel.conf

Section "OutputClass"
    Identifier "intel"
    MatchDriver "i915"
    Driver "modesetting"
    Option "AccelMethod" "none"

But you would have to remove this file each time you want to switch to intel.
In case you’ll try, attach a new output of
sudo journalctl -b 0 --no-pager _COMM=gdm-x-session >xsession.log

I am assuming you meant to put the above file file in /usr/share/X11/xorg.conf.d/ as there is no /etc/X11/xorg.conf.d/ directory? I created the file and rebooted. The resulting xsession file is attached in the post above. Again still no second monitor is seen.
Thanks again for all the help.
xsession.log (76.3 KB)

/etc/X11/xorg.conf.d/ is the standard place for user created config snippets, looks like 18.04 doesn’t create that any more, nevermind.
Everything is configured right now yet the nvidia driver still doesn’t probe for outputs. So this is either a general bug with the upgraded xserver 1.19.6 or the nvidia driver 396.24. Can you downgrade the driver to 390.x using the Software&Updates application?

To roll back to 390.x I needed to remove nogpumanager from the kernel parameter line. If I didn’t I couldn’t get beyond the login screen. I would try to log in and would get bounced right back to login. Going back to 390.x didn’t help. Still no second monitor. I attached xsession.log in my above post. I also tried Nouveau as the driver and couldn’t see a second monitor. I wonder if this points to xserver 1.19.6 as the culprit. Though strange that the intel board works or is this not using xserver?

Another strange observation is that when a second monitor is connected if I boot up when I get to the login screen, the login names are missing as well, the Xsession selections are messed up . It may show something like :
Gn m
Ub tu on X g
Wa y nd
etc. instead of :

Ubuntu on Xorg

Not sure why this would be? Maybe a gdm bug?
This is quite a mess. Maybe I just have to be patient and let Ubuntu sort things out.

It’s really a mess. Be sure to report those three bugs to Ubuntu.
As the xsession.log only contains the log from your user session, I suspect that gd uses a wayland session. Try forcing it to a Xorg session as well:
In the file
uncomment/add the line
so it reads
and reboot.

If that doesn’t change anything, you could only use an old-style xorg.conf other than waiting for Ubuntu fixing this.

Section "ServerLayout"
    Identifier     "layout"
    Screen      0  "nvidia" 0 0
    Inactive       "intel"

Section "Monitor"
    Identifier     "Monitor0"
    Modeline "1280x720_60.00"  74.48  1280 1336 1472 1664  720 721 724 746  -HSync +Vsync

Section "Device"
    Identifier     "intel"
    Driver         "modesetting"
    Option         "AccelMethod" "none"
    BusID          "PCI:0:2:0"

Section "Device"
    Identifier     "nvidia"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BusID          "PCI:1:0:0"
    Option         "AllowEmptyInitialConfiguration"

Section "Screen"
    Identifier     "nvidia"
    Device         "nvidia"
    Monitor        "Monitor0"
    SubSection     "Display"
        Virtual     1920 1080

You might have to use nogpumanager in order to keep gpumanager erasing it on start.

I guess Ubuntu 18.04 uses gdm3 so I found the file at /etc/gdm3/ . When logging in it seems my Login Name or Xsession choice wasn’t messed up with a second monitor attached. I will watch on future boots to see if that sticks. It also removed Wayland as a choice. So can no longer login with a Wayland session. Adding the xorg.conf file didn’t fix anything with respect to a second monitor. I booted in using nogpumanager. Would I need to add a Monitor1, Device1 and Screen1 section to that xorg.conf file to be able to use a second monitor however?

So adding to the weirdness. I now notice that if I keep WaylandEnable=false and look at “top” . Xorg is using 200% cpu. I switched back and forth between true and false a couple of times to confirm this. At one point Xorg even crashed I guess because it was using so much cpu. I have gone back to WaylandEnable=true

Just had some success. I decided to try lightdm instead of gdm3 and it WORKED. The second monitor is detected and controlled. I guess I will go back to the original configuration and get rid of nogpumanager. Hopefully it will all be good otherwise will keep it. Thanks again so much for your help. I really appreciate all the help. I have learned a lot from your guidance. Cheers!

What a nightmare. But this reminds me of the gdm bug first introduced in 17.10, some users here found a workaround at that time, starting and stopping a xserver before gdm starts. Thought Ubuntu had fixed that. At least you found a working solution.