Complex setup with Nvidia Optimus / Nouveau Prime on Fedora 20

This is a re-edit of my previous post about using and configuring an Optimus enabled laptop in Fedora 20/21. It should work on other distributions as well.

optimus_technology_badge

My laptop at work is a Dell Latitude E6430. Comes loaded with features and I really like it. Among the various features there’s the fact that this is an Nvidia Optimus enabled laptop, sporting both an Intel video card and an Nvidia one:

$ lspci | grep -i vga
00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)
01:00.0 VGA compatible controller: NVIDIA Corporation GF108GLM [NVS 5200M] (rev a1)

This one is a muxless laptop of the worst kind: video outputs are connected only to specific chips!

Update 23rd May 2014: UEFI console (using efifb) on external monitors has been fixed with bios update version “A14”. Now the UEFI console is also rendered on external monitors if the lid is closed; so I’ve updated the guide.

LVDS (Internal panel)Intel
VGA (not usable along with the docking station one)Intel
VGA (Docking station)Intel
DVINvidia
DVI (Docking station)Nvidia
DisplayPort (Docking station)Nvidia
HDMINvidia

So to use an external HDMI connection at home you need to drive it through the Nvidia card, it doesn’t matter if Optimus is enabled or not. I regularly use it docked with the lid closed, external keyboard and mouse and 2 external monitors connected to the VGA and DVI outputs of the docking station. Basically while I’m at the office it looks like a normal desktop computer; but sometime I need to disconnect it to go on a meeting; and sometimes I use it at home to play games as well.

Guess what? Free drivers, proprietary drivers, UEFI, UEFI secure boot, multi monitor, outputs changing on the fly… all sorts of fun! I’m impressed by the fact that it all works together.

There are four modes on which I can operate the system:

  • Optimus enabled, free drivers for both Intel and Nvidia cards (implementation is called “Prime”)
  • Optimus enabled, free driver for Intel and proprietary driver for the Nvidia card
  • Optimus disabled, free driver for the Nvidia card
  • Optimus disabled, proprietary driver for the Nvidia card

Each one has its drawbacks, so let’s explain each setup a bit. At the end of the post I’ve made a table with all the pros and cons of each solution.

My current setup is:

  • Fedora 20 x86_64
  • Kernel 3.14.4 (stock Fedora)
  • Nouveau DDX 1.0.9 (stock Fedora)
  • Intel DDX 2.21.15 (stock Fedora)
  • Nvidia proprietary drivers 337.19 (from my repository)
  • VDPAU library 0.7 (stock Fedora)
  • Mesa libraries 10.1.3 (20140509 prerelease, stock Fedora)

UEFI / legacy bios

If secure boot is enabled; there’s no way to use the proprietary Nvidia driver without fiddling with UEFI keys. The module is built separately from the kernel package; so there’s no way for it to have the same signature as the kernel.

When UEFI is enabled, the free drivers work fine and replace the efifb framebuffer driver with their own; thus giving proper modesetting at the correct resolution and a speedy and responsive terminal.

With the proprietary Nvidia driver, the efifb is not replaced; so the console still operates with it and the Nvidia driver only operates the X part. Unfortunately, using this method, the framebuffer console is really slow, the resolution is not optimal, and the EFI framebuffer is exposed onto external monitors only from bios version “A14”. Before the update, pressing CTRL+ALT+Fx jumped me to the console that is shown in the closed laptop lid on the docking station; making it pretty useless.

What UEFI could bring you is the Intel Rapid Start Technology which has been included in kernel 3.11; so make your choices depending on what you need.

Optimus disabled (Nouveau or Nvidia)

When Optimus is disabled, I can freely use the proprietary Nvidia driver or the free Nouveau driver.

Both solutions work; unfortunately performance and feature wise Nouveau cannot compete with the proprietary Nvidia driver.

My main issue is power management; with the Nvidia driver the battery lasts a lot more and the performance difference is abysmal. Nouveau performance is really poor with 3D games (especially Steam commercial ones, with Doom 3 it works fine) and there’s absolutely no power management; at least on my laptop. By playing with performance levels I was only able to overheat the card.

Another thing that does not work with Nouveau is the docking station removal. With the Nvidia proprietary driver I’m able to do the following:

– Disconnect from the docking station: output goes from the external VGA and DVI monitors to the internal LVDS display.

– Reconnect to the docking station: internal LVDS display gets shut off and output goes to VGA and DVI monitors as they were before; one next to the other. I can even close the lid and the computer doesn’t go in standby.

With Nouveau, I’m able to disconnect from the docking station but when reconnecting I need to reconfigure the monitors in their place; and after this, when closing the lid I need to wake up again the computer because it goes on standby.

With the recent Xrandr support to the proprietary drivers I don’t even need to edit che X.org configuration file. Whether I use nvidia-settings or Gnome Displays panel the result is reflected in both implementations and preserved across boots.

Optimus enabled (Nvidia)

To configure Optimus with proprietary drivers perform the following. First of all install the proprietary driver as normal. Now edit the /etc/grub2.cfg file and remove some parameters from the kernel command line. This is required because the Intel driver still need to operate with its KMS driver. So, from this:

nouveau.modeset=0 rd.driver.blacklist=nouveau nomodeset gfxpayload=vga=normal

you should go to this:

nouveau.modeset=0 rd.driver.blacklist=nouveau

After this, edit/recreate the /etc/X11/xorg.conf file with the following contents:

Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
    Option "NoLogo" "true"
    Option "DPI" "96 x 96"
    # Specify Nvidia PCI device
    BusID "PCI:1:0:0"
    # Make sure X starts also when no outputs are connected to the Nvidia chip
    Option "AllowEmptyInitialConfiguration"
EndSection

# Slave device
Section "Device"
    Identifier "intel"
    # Simple output, no full Intel driver
    Driver "modesetting"
    # BusID "PCI:0:2:0"
EndSection

Section "Screen"
    Identifier "intel"
    Device "intel"
EndSection

Section "Screen"
    Identifier "nvidia"
    Device "nvidia"
EndSection

# Make sure the Nvidia device is the first in the server
Section "ServerLayout"
    Identifier "layout"
    Screen 0 "nvidia"
    Inactive "intel"
EndSection

Make sure to set the correct bus ID for the Nvidia card; for instructions look in the Nvidia documentation. Make sure the integrated Intel card is using modesetting driver and not the native one.

The AllowEmptyInitialConfiguration directive in the Nvidia section is required to let X start with the Nvidia driver without any output attached to the chip, for example while using the internal LVDS monitor.

Upon reboot, you will see KMS running for the Intel card (Plymouth screen) and then the login manager appears on the Nvidia attached panels, while the Intel outputs shut off.

After logging in, you can also check that both drivers are running with the following commands:

$ lsmod | egrep "i915|nvidia"
nvidia              10411255  41 
i915                  796218  2 
i2c_algo_bit           13257  1 i915
drm_kms_helper         50652  1 i915
drm                   283747  5 i915,drm_kms_helper,nvidia
i2c_core               38656  7 drm,i915,i2c_i801,drm_kms_helper,i2c_algo_bit,nvidia,videodev
video                  19261  1 i915

To light up the other display some xrandr command is required:

$ xrandr --setprovideroutputsource Intel NVIDIA-0
$ xrandr --auto

Your Intel monitor should now have an extended desktop managed by the Nvidia card. Move windows around, and launch some commands to see that wherever you go you’re using the Nvidia accelerated driver:

$ glxinfo| grep "OpenGL version string"
OpenGL version string: 4.4.0 NVIDIA 337.19
$ vdpauinfo | grep -i string
Information string: NVIDIA VDPAU Driver Shared Library  337.19  Tue Apr 29 19:51:41 PDT 2014

Everything seems to work, except output manipulation. Xrandr, Gnome and Nvidia drivers have a different view.

Xrandr view:

$ xrandr -q | grep conn
VGA-0 disconnected (normal left inverted right x axis y axis)
LVDS-0 disconnected (normal left inverted right x axis y axis)
DP-0 disconnected (normal left inverted right x axis y axis)
DP-1 connected primary 1680x1050+0+0 (normal left inverted right x axis y axis) 474mm x 296mm panning 3360x1050+0+0
HDMI-0 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 disconnected (normal left inverted right x axis y axis)
LVDS-1-0 connected (normal left inverted right x axis y axis)
VGA-1-0 connected 1680x1050+1680+0 (normal left inverted right x axis y axis) 474mm x 296mm

This is what I have in the Nvidia settings panel and in the Gnome Displays panel for the monitors; in one case I see only one of the external monitors, in the other one I have all monitors:

Primary monitor assignment does not work as well. I usally have the Gnome panel on the left monitor. If I try to move it from the Nvidia output I get this feedback:

$ xrandr --output VGA-1-0 --primary
X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  139 (RANDR)
  Minor opcode of failed request:  30 (RRSetOutputPrimary)
  Serial number of failed request:  51
  Current serial number in output stream:  53

Putting monitor problems aside, running in this mode does not really give any benefit compared to running it with Optimus disabled and the proprietary Nvidia driver installed. Both cards are running with power management, but the Nvidia card is never shut off, so it doesn’t use less power than when running standalone.

There’s no way to turn off the card with vga_switcheroo, all libraries come from the Nvidia drivers and your desktop is being rendered by the Nvidia card.

GDM configuration for Optimus (Nvidia)

Let’s assume you want to create the above setup in GDM (Gnome Display Manager), making it run automatically the xrandr commands mentioned above.

You need to create a text file with the display name (usually “:0”) to start the commands upon Init time the appropriate GDM configuration directory:

$ cd /etc/gdm/Init/
$ cat \:0 
#!/bin/sh

# Get the xrandr providers
output="$(xrandr --listproviders)"

src=$(echo "$output" | grep " Source" | head -n1 | awk '{print $NF}' | cut -d: -f2)
sink=$(echo -e "$output" | grep " Sink" | head -n1 | awk '{print $NF}' | cut -d: -f2)

# Pass provider or sink and source
xrandr --setprovideroutputsource "$sink" "$src"

# Make sure xrandr sees all the outputs
# xrandr --auto

# Do not move up. Only now xrandr shows the outputs
lvds=$(xrandr | grep -i "lvds" | head -n1 |cut -d " " -f 1)
xrandr --output "$lvds" --off
xrandr --output "$lvds" --auto

The “–off” and then “–auto” is actually redundant, but it helped in a couple of cases.

Prime enabled (Nouveau)

The Open Source implementation of this is actually called “Prime” for obvious reasons.

Here comes the juicy part. With enough maturity on the Nouveau side this would be the perfect setup. To start with this implementation; nothing is required, just install Fedora and everything should be already set up by default. Booting it shows the Plymouth logo on both outputs.

Login in the system, and check that both drivers are running:

$ lsmod | egrep "i915|nouveau"
nouveau               943445  1 
i915                  651861  4 
mxm_wmi                12865  1 nouveau
ttm                    79865  1 nouveau
i2c_algo_bit           13257  2 i915,nouveau
drm_kms_helper         50239  2 i915,nouveau
drm                   274480  8 ttm,i915,drm_kms_helper,nouveau
i2c_core               34242  7 drm,i915,i2c_i801,drm_kms_helper,i2c_algo_bit,nouveau,videodev
wmi                    18697  3 dell_wmi,mxm_wmi,nouveau
video                  19104  2 i915,nouveau

Poking around with xrandr will give you totally different outputs from the Nvidia driver:

$ xrandr -q | grep conn
LVDS2 connected 1600x900+0+0 (normal left inverted right x axis y axis) 309mm x 174mm
VGA2 connected 1680x1050+1600+0 (normal left inverted right x axis y axis) 474mm x 296mm
LVDS-1-1 disconnected (normal left inverted right x axis y axis)
DP-1-1 disconnected (normal left inverted right x axis y axis)
DP-1-2 connected (normal left inverted right x axis y axis)
HDMI-1-1 disconnected (normal left inverted right x axis y axis)
VGA-1-1 disconnected (normal left inverted right x axis y axis)

But at least they’re consistent with the Gnome Displays panel:

For reasons I don’t understand the Nvidia card appears twice in 2 different but identical providers:

$ xrandr --listproviders
Providers: number : 3
Provider 0: id: 0x96 cap: 0xb, Source Output, Sink Output, Sink Offload crtcs: 3 outputs: 2 associated providers: 2 name:Intel
Provider 1: id: 0x66 cap: 0x7, Source Output, Sink Output, Source Offload crtcs: 2 outputs: 5 associated providers: 2 name:nouveau
Provider 2: id: 0x66 cap: 0x7, Source Output, Sink Output, Source Offload crtcs: 2 outputs: 5 associated providers: 2 name:nouveau

With the tests I made, there’s no apparent difference when using one or the other. Usage of one card or the other is driven by the DRI_PRIME environment variable. If it’s set to 0, commands run on the Intel card, if it’s set to 1 they will run on the Nvidia card. For example:

$ DRI_PRIME=1 vdpauinfo | grep -i string
Information string: G3DVL VDPAU Driver Shared Library version 1.0

Or even better, to check OpenGL status:

$ glxinfo | grep -e 'OpenGL.*string.*'
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Ivybridge Mobile 
OpenGL core profile version string: 3.3 (Core Profile) Mesa 10.1.3
OpenGL core profile shading language version string: 3.30
OpenGL version string: 3.0 Mesa 10.1.3
OpenGL shading language version string: 1.30
$ DRI_PRIME=1 glxinfo | grep -e 'OpenGL.*string.*'
OpenGL vendor string: nouveau
OpenGL renderer string: Gallium 0.4 on NVC1
OpenGL core profile version string: 3.3 (Core Profile) Mesa 10.1.3
OpenGL core profile shading language version string: 3.30
OpenGL version string: 3.0 Mesa 10.1.3
OpenGL shading language version string: 1.30

Unfortunately the desktop is very slow, it’s rendered by the Intel driver and put on the Nvidia card for display. I’ve tried changing priority in vga_switcheroo prior to starting X, setting the DRI_PRIME=1 variable at boot, use xrandr to change the provider output source etc. to no avail; the desktop can run only on the first card or it doesn’t work. Usually I get a black screen upon GDM start.

There’s no power management as well, so the Intel card runs normally but the Nvidia one is always on and stuck in an intermediate performance level.

When docking it; I get cloned outputs on all external displays at a very low resolution. Same issue with the Optimus disabled Nouveau driver; the outputs need to be rearranged, the lid closed and the computer needs to be woken up from standby.

Prime power management (Nouveau)

Power management for automatic powerup/shutdown of cards in Optimus systems and runtime management has been introduced in kernel 3.12. Is on by default on Optimus enabled laptops and is enabled by default.

The situation has improved a lot in 3.13 and 3.14, and at least on my system it works flawlessly:

# cat /sys/kernel/debug/vgaswitcheroo/switch 
0:IGD:+:Pwr:0000:00:02.0
1:DIS: :DynPwr:0000:01:00.0

As you can see the second card is dynamically powered. Try to undock the system and check the status again: the second output is no longer needed so the second card shuts off:

# cat /sys/kernel/debug/vgaswitcheroo/switch 
0:IGD:+:Pwr:0000:00:02.0
1:DIS: :DynOff:0000:01:00.0

Now, with the laptop undocked, launch a command on the second card:

# DRI_PRIME=1 vdpauinfo | grep -i string
Information string: G3DVL VDPAU Driver Shared Library version 1.0
# cat /sys/kernel/debug/vgaswitcheroo/switch 
0:IGD:+:Pwr:0000:00:02.0
1:DIS: :DynPwr:0000:01:00.0

You will notice a slight delay before the command output is returned, but the card is powered on again! This is awesome. Now, after 1 or 2 seconds look again at the card:

# cat /sys/kernel/debug/vgaswitcheroo/switch 
0:IGD:+:Pwr:0000:00:02.0
1:DIS: :DynOff:0000:01:00.0

It’s shut off! Dock the laptop again and the monitor should come up again.

Keep in mind that powering up and down cards is a totally different things than power managing and adjusting clocks etc. for a running card. This make the Nvidia card shutdown automatically, not regulate its power levels during usage.

Dual cards can be shut down or powered up on demand through vga_switcheroo. For example, login in your system as root without X running and no outputs connected to the Nvidia chip. Look at the card status with the following command:

# cat /sys/kernel/debug/vgaswitcheroo/switch
0:IGD:+:Pwr:0000:00:02.0
1:DIS: :DynOff:0000:01:00.0

This will tell you that the Integrated Graphics Display (IGD) is powered up (Pwr) and that is the primary display (+), while Discrete one (DIS) is dynamically off. To turn on the secondary video card, a single command is required:

# echo > /sys/kernel/debug/vgaswitcheroo/switch
# cat /sys/kernel/debug/vgaswitcheroo/switch
0:IGD:+:Pwr:0000:00:02.0
1:DIS: :On:0000:01:00.0

This will power on the Nvidia card. A look at the battery will tell you now that you have half the power because the Nvidia card sucks power along the integrated Intel one.

Turn off the integrated card (IGD), and switch the framebuffer console to the discrete one (DIS):

# echo DDIS > /sys/kernel/debug/vgaswitcheroo/switch
[  879.436727] i915: switched off
# cat /sys/kernel/debug/vgaswitcheroo/switch
0:IGD: :Off:0000:00:02.0
1:DIS:+:Pwr:0000:01:00.0

This will move the framebuffer and your shell to the other Nvidia driven monitor and shut down the Intel card. You will see the framebuffer console on the Nvidia output. Sweet, isn’t it?

Summary

A Prime enabled laptop with open source drivers does not have any configuration and does not require any manual configuration. The fact that the Nvidia card can power down itself is great and doubles my battery duration! On the screen I have KMS consoles without huge fonts and can have UEFI secure boot enabled! This is really awesome.

Unfortunately though, without proper Nouveau power management and performance improvements added to the fact that I need to reconfigure monitors everytime I move (sometime the output gets all black as well when docking); the experience is not that great. I don’t know why, but when I’m undocked and using only the LVDS internal panel, the Intel performance is fantastic. Problems arise only when it’s docked and Nouveau is enabled as well.

OptimusDisabledDisabledEnabledEnabled (Prime)
DriverNvidiaNouveauIntel/NvidiaIntel/Nouveau
ConfigurationVery easy.Already set up.Very complexAlready set up.
Card power
management
Perfect!Poor performance, no power management.Nvidia card always powered up, renders for all screens.Dynamic video card switching works fine, Nouveau performance not.
Optimus card
power management
N.A.N.A.Nvidia card can't power down.Perfect!
Docking / UndockingPerfect!Manual intervention requiredManual intervention required, unreliableManual intervention required
PerformancePerfect!Pretty bad.Very good, some tearing when moving windows.Bad when using the Nvidia card for output, otherwise perfect!
Bios ConsoleVGA, no KMS.Perfect (KMS)!Perfect (KMS on Intel).Perfect (KMS)!
UEFI ConsoleUses efifb. Somewhat slow.Perfect (KMS)!Perfect (KMS on Intel).Perfect (KMS)!
UEFI secure bootCan't work.Perfect!Can't work.Perfect!

Summing up, my current choice is for the Optimus disabled setup with Nvidia drivers. I can play games, dock, undock, power management works ok and I can drive all outputs easily. And if I need to go in a meeting I don’t need to be extra cautious in shutting down virtual machines, because the system might not go up again. It’s kinda retro style when booting with the text console and battery does not last more than 3 hours, but I can bear it.

If you’re not hunger for games or 3d stuff except the usual desktop compositing, just stick with the default OpenSource drivers and components, there is no setup required and everything works out of the box. My battery charge lasts usually 6 hours on a mixed usage case.

Nvidia has started contributing to the Nouveau driver with support for the GK20A (Nvidia K1) chip and it will be merged in kernel 3.16; let’s hope it will do the same for the other chips and components.

45 thoughts to “Complex setup with Nvidia Optimus / Nouveau Prime on Fedora 20”

    1. Thanks for feedback. I don’t have an Optimus laptop anymore. What distribution/cards/output combination are you using?
      I’m curious if it still works.

  1. I’m not sure what changed, but on Fedora 23, xrandr doesn’t see any modes for my Intel screen. On Fedora 22, this was never an issue. I don’t know if something changed in Xorg or the nvidia drivers or otherwise that caused this issue.

    I normally use udev triggers to ‘sense’ when I dock and undock. But I’m forced to keep my laptop docked 100% of the time because I cannot get the laptop screen to appear. I have to remove the nvidia drivers to get it to come back. Shouldn’t have to do that.

    If you (or anyone else) has any advice to get around this issue, that would be awesome. Below are my configs and information. I tried using ‘modesetting’ at one point without success.

    Current grub /proc/cmdline: BOOT_IMAGE=/vmlinuz-4.2.8-300.fc23.x86_64 root=/dev/mapper/fedora_diurne-root ro rd.lvm.lv=fedora_diurne/root rd.lvm.lv=fedora_diurne/swap rhgb quiet LANG=en_US.UTF-8 nouveau.modeset=0 rd.driver.blacklist=nouveau nomodeset gfxpayload=vga=normal
    http://paste.fedoraproject.org/307450/45201188/

    1. I’m sorry but I don’t have an Optimus enabled laptop anymore, before giving it back I was running Fedora 22.

  2. Every weekend i used to pay a visit this website, ass i wish for enjoyment, as this this web page conations in fact pleasant funny
    stuff too.

  3. Hi!
    I use “Optimus enabled (Nvidia)” way.
    Fedora 22, Asus N55s laptop, Intel/Nvidia card.
    My results https://www.dropbox.com/s/9uir32wdjf4nnp0/Xorg.0.log?dl=0

    [ 221.932] (EE) Backtrace:
    [ 221.934] (EE) 0: /usr/libexec/Xorg (OsLookupColor+0x139) [0x59a1d9]
    [ 221.935] (EE) 1: /lib64/libc.so.6 (__restore_rt+0x0) [0x7f1d74defb1f]
    [ 221.935] (EE) 2: /lib64/libX11.so.6 (_XSend+0xd9) [0x7f1d6af34b99]
    [ 221.935] (EE) 3: /lib64/libX11.so.6 (_XFlush+0x15) [0x7f1d6af34fa5]
    [ 221.936] (EE) 4: /lib64/libX11.so.6 (_XGetRequest+0x55) [0x7f1d6af37b25]
    [ 221.936] (EE) 5: /lib64/libX11.so.6 (XQueryExtension+0x4d) [0x7f1d6af2b0bd]
    [ 221.936] (EE) 6: /lib64/libX11.so.6 (XInitExtension+0x32) [0x7f1d6af1ec62]
    [ 221.936] (EE) 7: /lib64/libXext.so.6 (XextAddDisplay+0x4f) [0x7f1d6aced18f]
    [ 221.936] (EE) 8: /usr/lib64/nvidia/libnvidia-glsi.so.346.72 (_nv016glsi+0x5f437) [0x7f1d6b2f5457]
    [ 221.936] (EE) 9: /usr/lib64/nvidia/libnvidia-glsi.so.346.72 (_nv016glsi+0x804) [0x7f1d6b237bf4]
    [ 221.937] (EE) unw_get_proc_name failed: no unwind info found [-10]
    [ 221.937] (EE) 10: /usr/lib64/nvidia/libEGL.so.1 (?+0x804) [0x7f1d6b4e0ef4]
    [ 221.937] (EE) unw_get_proc_name failed: no unwind info found [-10]
    [ 221.937] (EE) 11: /usr/lib64/nvidia/libEGL.so.1 (?+0x804) [0x7f1d6b4e1924]
    [ 221.937] (EE) 12: /usr/lib64/nvidia/libEGL.so.1 (NvEglRegClientApi+0x4f36) [0x7f1d6b4ee866]
    [ 221.937] (EE) 13: /usr/lib64/xorg/modules/libglamoregl.so (glamor_egl_init+0x9a) [0x7f1d6d87943a]
    [ 221.938] (EE) 14: /usr/lib64/xorg/modules/drivers/modesetting_drv.so (_init+0x29d0) [0x7f1d6df0fe90]
    [ 221.938] (EE) 15: /usr/libexec/Xorg (InitOutput+0xbb0) [0x47d710]
    [ 221.938] (EE) 16: /usr/libexec/Xorg (remove_fs_handlers+0x22a) [0x43e28a]
    [ 221.939] (EE) 17: /lib64/libc.so.6 (__libc_start_main+0xf0) [0x7f1d74ddb790]
    [ 221.939] (EE) 18: /usr/libexec/Xorg (_start+0x29) [0x428869]
    [ 221.939] (EE) 19: ? (?+0x29) [0x29]
    [ 221.939] (EE)
    [ 221.939] (EE) Segmentation fault at address 0x7f1d6bf53078

    Tell me what to do? Help!))

  4. Hi!

    First off. i am really glad that you have written this articles because I have the exact same laptop 🙂

    As it is with most things, you have to learn some fundamental concepts to really understand the essence of what you are going to do or are currently doing. For me this has been a travel where I learn how Linux ticks with graphics cards.

    I didn’t use your driver, but I used your suggestion about disabling optimus and using nvidia only.

    What I did was disabling optimus in bios, adding blacklist file for nouveau, also blacklisting it in grub, remade grub, uninstalled nouveau driver and then rebuilded initramfs. Then i sat default runlevel to 3, installed nvidia driver from their website and bam. It worked. The story in between was a boring travel, where i didnt know how to disable nouveau. Nvidia setup complained like 10-20 times before I managed to disable nouveau.

    The story now continues with kernel updates that will break the driver, but at least fedora 21 is not updating automatically, so I can control when i update and i can also exclude kernels.

    And oh, I removed the ugly splash screen with NoLogo. Cant understand why they added it really.

    1. Hello, may I ask you why you are not using the packages but instead rerunning the setup from scratch (with all problems associated)?

      1. If there is anything that you think is missing and should be improved in the packages please let me know.

  5. slaanesh, I was wondering what it’s changing the installation of nvidia-driver. I mean, I am able to start the LVDS without the NVIDIA drivers or the HDMI with them…. to switch from one situation to the other, I uninstall the nvidia-driver which it’s a time consuming tasks.

    I’ve tried the following steps:

    1) Install the nvidia-drivers.
    2) Delete the xorg.conf
    3) Let grub.conf as before of the installation
    4) Reboot

    But the X continues failing. Am I missing something?

    1. To restore it back, make sure to have no xorg.conf, no Nvidia libraries overriding the system ones (this should be taken care of by removing packages) and that the nvidia module is not loading (again taken care of by removing packages).

      Unfortunately there is no way to switch (yet). For making GL libraries match the screen being used there is the libglvnd project being worked on by Nvidia [1] and Red Hat [2] [3] while kernel wise you have to wait until Nvidia starts contributing more documentation to Nouveau [4] and releases firmware images for the latest cards.

      [1] https://github.com/NVIDIA/libglvnd
      [2] https://github.com/nwnk/libglvnd
      [3] http://cgit.freedesktop.org/~ajax/mesa/log/?h=glvnd
      [4] ftp://download.nvidia.com/open-gpu-doc/

  6. IMO, it’s like your laptop:

    LVDS and VGA -> Intel
    HDMI -> Nvidia

    I was able to have both of them using bumblebee and two X servers up differently with Ubuntu and later, with a newer version of Ubuntu without bumblebee, only with the Nvidia drivers.

    But now I am using RedHat based distribution with an old kenel (I’ve posted it before), I think the problem is more related to that.

    1. I don’t really know, same kernel here on Dell E6430 works (I also test packages on CentOS).

      Kernel wise it should be ok, as you mentioned that with free drivers it was working (although sluggish).

      1. I am going to try again with Noueveau but probably I would buy a new laptop, and this time without Nvidia card, I’ve spent too much time trying to fix it.

        Thanks for your help, slaanesh. Your blog and knowledge about this is amazing.

  7. I’ve deleted the primary option and I’ve recreated the :0 script (I deleted it before because with it the session is closed when I return after block it).

    Anyway, I reboot without the HDMI connected but the LVDS screen is black. This is the log: http://pastebin.centos.org/15866/

    After change to the intel driver, it happens the same when HDMI is disconnected (log http://pastebin.centos.org/15861/ ) but I am not able to login (session closes in the moment) when HDMI is connected.

    I see the Segmentation fault in both logs but no idea how avoid it.

    1. Mmh, I don’t know why it’s crashing. If there is something wrong the server should just throw out an error; not crash entirely. Maybe there is some quirk or bug specific to your device?

      Are the connections in your laptop connected to both cards or each card is driving some connector (like my laptop in the post)?

  8. Hello slaanesh,

    I’ve tried with intel/nouveau, it works everything as you said but the quality is really bad, I see mouse trails, late updates in the screen and so on… no idea how improve that.

    With the nvidia drivers I am able to work with HDMI but not with LVDS…

    This is the xorg.conf I am using rigth now: http://pastebin.centos.org/15851/
    and log http://pastebin.centos.org/15856/

    It’s weird, if I execute:
    $ xrandr –setprovideroutputsource Intel NVIDIA-0
    $ xrandr –auto

    Both screens are up but LVDS is a clone of HDMI with exactly the same resolution (which it’s not supported). If I try to change it or turn off the HDMI screen, the GDM sessions dies and I have to login again in the HDMI Screen, with the LVDS off.

    This is really painful, I feel really lost, thanks for your help!

    1. As I write in the previous reply, first of all remove Option "Primary" "true" from the Nvidia driver setting. Also, have you added the code snippet for the xrandr commands at GDM startup (GDM configuration for Optimus) section? If the monitor lits up after a manual xrandr command, probably you did not add it.

      After the above, try to use the driver “intel” instead of “modesetting” in the Intel device section to see if that helps.

  9. Hi slaanesh,

    I spent a lot of hours trying to setup this but I am blocked, some guidance would be great.

    I have an ASUS N56V with two cards:

    $ lspci | grep VGA
    00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)
    01:00.0 VGA compatible controller: NVIDIA Corporation GF108M [GeForce GT 630M] (rev a1)

    It’s running a RedHat based-distribution,

    $ uname -a
    Linux toni 3.10.0-123.20.1.el7.x86_64 #1 SMP Wed Jan 28 12:39:44 PST 2015 x86_64 x86_64 x86_64 GNU/Linux

    And I would like to work in these modes:
    – Only HDMI (if available)
    – Only LVDS (not docked)
    – LVDS and HDMI or VGA (for presentations)

    I don’t care loose the session/reboot to change from one to another one and I can live without power management.

    Following your instructions in Optimus enabled (Nvidia), I am able to work in only HDMI but it’s imposible to work only with LVDS (without HDMI). I’ve attached the xorg log here: http://fpaste.org/181292/

    I’ve tried also with Nouveau but even I don’t play games I found a lot of problems with perfomance or setting up the Intel driver.

    Any help on this would be welcomed

    1. Hello, as depicted in the post, my suggestion is to use the free drivers combo (intel/nouveau) and let the system manage everything for you. The Nvidia card should be off if you are using the laptop undocked (only the LVDS screen on).

      Looking at your log, I found these entries:

      [     2.785] (WW) "xwayland" is not to be loaded by default. Skipping.
      [     3.634] (WW) modesetting(G0): Option "Primary" is not used
      [     3.945] (WW) NVIDIA(0): Option "Primary" is not used

      Do you have some extra entries in the xorg.conf file apart from those I pasted in the post?

  10. My Optimus laptop runs the display on the Intel GPU, and as such there’s no way to disable Optimus but still be able to use the Nvidia GPU. Is there any way other than using Bumblebee’s optirun (my current solution) to use the Nvidia GPU to play games? No external monitors involved.

    1. This is exactly what the article is about. Using Optimus (intel/nvidia), rendering is always done on the Nvidia card. In Prime (intel/nouveau), you choose where to run the task with DRI_PRIME.

      1. Oh, OK! I was confused because it sounds like the setup is for laptops with the monitor connected to the nvidia card, e.g.:

        “Upon reboot, you will see KMS running for the Intel card (Plymouth screen) and then the login manager appears on the Nvidia attached panels, while the Intel outputs shut off.”

        But I will definitely give it a try later. Thanks!

        1. I added the xrandr script in the “GDM configuration for Optimus” section and now the display is “lit up” (backlit) but still blank. Is there any way for this to work without using an external monitor? Thank you

  11. My laptop is a Dell E6520 and the native Optimus enabled solution is really awesome
    …but…
    …nouveau performances are very discouraging: on external monitor I see mouse trails, invalid text cursor, bad background refresh…
    There are still too many problems!
    X-(

  12. Hello,

    i wanted to try this guide again, since i really like Fedora but need my NVidia Card working. Im not that experienced with Linux.

    I tried this guide yesterday (installed the Drivers from Rpmfusion Repos) and after the first reboot i dont get the GDM Login screen (plymouth works fine on both screens)

    My Laptop is a Acer Aspire 5742g and i want to use an external Screen on HDMI. Most important is that my whole Desktop gets rendered by the NVidia Card, battery life is not important since i use the laptop as a desktop PC actually. If i understand your post correctly this should be possible (just like it is in Ubuntu with the nvidia-prime package).

    Im currently installing a vanilla Fedora and want to try it again.

    1. Can you tell me if i need to install the nvidia drivers from your repo?

    2. How can i analyse what the cause is if i dont see the GDM Screen again after the first reboot?

    1. Hi,

      so i tried it again and got the same result – the Screen stays black after Plymouth (with and without an external Monitor on HDMI). I dont see any Errors in xorg.log. How can i troubleshoot this?

  13. ok, so…since I need to drive 3…i need to use Optimus…and all was working well till something screwed up and now it seems that panning is enabled by default for Nvidia card and cannot disable it…any clue?

    1. Nicola,

      I’m trying to accomplish the same as you… Except I want to use the internal display and two external monitors on DVI. I had this working with the nouveau drivers but the external displays were slow. How did you get it working with the NVidia drivers?

      1. Thanks for the help with this. I was able to get optimus running with the NVIDIA drivers and 3 screens on my Dell laptop (running through my docking station (DVI, LVDS, VGA) with power saving. My setup is Fedora 20 (version info: 3.15.10-200, nvidia akmod akmod-nvidia-331.104-1 and xrandr 1.4.2). I modified your script slightly (See below). The one thing that I notice is that the monitor running on my nvidia card (DP-0 in my case) wants to panning with every mouse move. However, sometimes if I set the fb to 1920×1080 (xrandr –fb 1920×1080) after all monitors are enabled the panning stops. I get an error but it works exactly how I want it to work. I don’t have an exact cause yet and it doesn’t make too much sense.

        Hope this helps and if someone figures out how to prevent the spanning from the beginning please share!

        ----------------- Modified Nvidia Script ---------------
        output="$(xrandr --listproviders)"
         
        src=$(echo "$output" | grep " Source" | head -n1 | awk '{print $NF}' | cut -d: -f2)
        sink=$(echo -e "$output" | grep " Sink" | head -n1 | awk '{print $NF}' | cut -d: -f2)
         
        # Pass provider or sink and source
        xrandr --setprovideroutputsource "$sink" "$src"
         
        # Make sure xrandr sees all the outputs
        # xrandr --auto
         
        # Do not move up. Only now xrandr shows the outputs
        #each one of these settings is determined by what connection is enabled.  use xrandr |grep -i " connected" to see what connectors are set
        #lvds=$(xrandr | grep -i "lvds" | head -n1 |cut -d " " -f 1)
        lvds=$(xrandr | grep -i "lvds" |grep -i " connected" | awk '{ print $1 }')
        dp=$(xrandr | grep -i "dp" |grep -i " connected" | awk '{ print $1 }')
        vga=$(xrandr | grep -i "vga" |grep -i " connected" | awk '{ print $1 }')
        
        
        xrandr --output "$lvds" --off --output "$vga" --off
        #xrandr --output "$lvds" --auto
        #xrandr --output "$vga" --auto
        
        #may need this first before the second one.  Not sure.
        #xrandr --fb 5760x1080  --output $dp --mode 1920x1080 --panning 5780x1080+0+0 --primary
        xrandr --fb 1920x1080
        xrandr --fb 5760x1080 --output $dp --mode 1920x1080 --primary --output $lvds --mode 1920x1080 --right-of $dp --output $vga --mode 1920x1080  --right-of $lvds
        
        #Sometimes the $dp screen is scrolling.  For some reason this prevents
        # it
        xrandr --fb 5760x1080
        xrandr --fb 1920x1080
        
        
        --------------------- xorg.conf -------------------------
        Section "Device"
            Identifier "nvidia"
            Driver "nvidia"
            Option "NoLogo" "true"
            Option "DPI" "96 x 96"
            VendorName     "NVIDIA Corporation"
            BoardName      "NVS 4200M"
            # Specify Nvidia PCI device
            BusID "PCI:1:0:0"
            # Make sure X starts also when no outputs are connected to the Nvidia chip
            Option "AllowEmptyInitialConfiguration"
            Option "ConstrainACursor" "0"
            Option "PanAllDisplays" "0"
            Option "nvidiaXineramaInfoOverride" "1920x1080+1280+0, 1920x1080+3840, 1920x1080+5760"
        EndSection
         
        # Slave device
        Section "Device"
            Identifier "intel"
            # Simple output, no full Intel driver
            Driver "modesetting"
            # BusID "PCI:0:2:0"
        EndSection
         
        Section "Screen"
            Identifier "intel"
            Device "intel"
        EndSection
         
        Section "Screen"
            Identifier "nvidia"
            Device "nvidia"
        EndSection
         
        # Make sure the Nvidia device is the first in the server
        Section "ServerLayout"
            Identifier "layout"
            Screen 0 "nvidia"
            Inactive "intel"
        1. I ran down with this some more. Essentially, you can prevent the scrolling by turning off the main nvidia screen and then turning it back on.

          Here’s the updated script:
          output=”$(xrandr –listproviders)”

          src=$(echo “$output” | grep ” Source” | head -n1 | awk ‘{print $NF}’ | cut -d: -f2)
          sink=$(echo -e “$output” | grep ” Sink” | head -n1 | awk ‘{print $NF}’ | cut -d: -f2)

          # Pass provider or sink and source
          xrandr –setprovideroutputsource “$sink” “$src”

          # Make sure xrandr sees all the outputs
          # xrandr –auto

          # Do not move up. Only now xrandr shows the outputs
          # Do not move up. Only now xrandr shows the outputs
          # each one of these settings is determined by what connection is
          # enabled. use xrandr |grep -i ” connected” to see what connectors are set
          lvds=$(xrandr | grep -i “lvds” |grep -i ” connected” | awk ‘{ print $1 }’)
          dp=$(xrandr | grep -i “dp” |grep -i ” connected” | awk ‘{ print $1 }’)
          vga=$(xrandr | grep -i “vga” |grep -i ” connected” | awk ‘{ print $1 }’)

          xrandr –output “$lvds” –off –output “$vga” –off –output $dp –off
          #xrandr –output “$lvds” –auto
          #xrandr –output “$vga” –auto

          #may need this first before the second one. Not sure.
          xrandr –output $lvds –mode 1920×1080 –right-of $dp –output $vga –mode 1920×1080 –right-of $lvds

          xrandr –output $dp –mode 1920×1080 –primary –output $lvds –mode 1920×1080 –right-of $dp –output $vga –mode 1920×1080 –right-of $lvds

  14. Hi Simone…
    great post…I just post a comment to see if you can help, since there’s not a lot of ppl trying this setup and you narrowed down all the possibilities!

    I’m actually using Ubuntu 14.04, not Fedora, but apart some configs I think it should be almost the same on problems coming from this configuration…

    I was using nvidia proprietary drivers 331 with nvidia-prime…all was working well and I could drive all my 3 external monitors (DP-0, DP-1 and VGA-1-0) indipendently just configuring them from Monitor Settings in Control Center (should be Gnome display)…

    I was though having problems with undock/dock as you stated but all was resolving with a reboot or two….
    10 days ago after an undock/dock I started having problems and even after rebooting I could not anymore my working config back….
    what I mean is that I have still the 3 monitors working, but DP-0 and DP-1 are panning into a large screen and it seems I cannot make them work indipendently!

    Do you have any suggenstions on what to look for to setup it correctly?
    Maybe I need to create 2 different screens both referring to Nvidia card?
    when I try to see into Nvidia-settings that seems to be the correct config but saving it from nvidia-settings doesn’t end in a working config…if you can help me, also privately if you want, I would be grateful.
    Thanks!

    1. Hello, Ubuntu does everything that is listed in this post and adds a button in the nvidia-settings control panel that does the following:

      – Generates the offload configuration and blacklists nouveau
      – Shut off the Nvidia one through the kernel module bbswitch from Bumblebee and remove the X.org configuration, using only the Intel one.

      Then you still have the limits in the monitor configuration for the offload scenario and no extra outputs usable like Display Port.

      If you generate the configuration file from nvidia-settings it will never work in an offload scenario as it cuts off all the existing settings. As I’ve written, the offload scenario is a bit of a hack and does not work properly in a lot of cases. So, unless you have a good reason for enabling it (that is an Optimus laptop where you need to play games but there’s no switch/bios option to turn off the Intel card) my suggestions are 2:

      – Disable Optimus in the bios and use the Nvidia drivers for gaming, external monitors, 4k, DP MST, etc.
      – Use only open drivers and leave Optimus enabled for optimal battery life, ease of use, etc.

      1. The problem, correct me if I’m wrong but I’m testing now, is that with Optimus disabled I can’t keep working concurrently Nvidia card and Intel one…and so I can’t drive 3 external monitors through docking station, since 2 are connected to the Nvidia card and 1 to the Intel card…am I missing some point?

        1. Your maximum number of monitors might vary depending on your Nvidia chipset; so it might be that your discrete card supports more than 2 monitors, but so far I’ve only stumbled across laptop video cards that support only 2 monitors. In this case what you’re saying is correct, you can drive 3 monitors only by using both video cards.

  15. Hi i like your description. But what i dont understand is: I want to use the Dell e6430 with two external Monitors and the internal Display of the Laptop and i am struggeling a lot: so maybe u can help me …

  16. You know, I’d really love to have a three-way conversation involving me, the person who thought these goddamn multi-GPU systems would be a good idea, and a large club with nails in it. Rusty nails.

    1. If you do, just call me, I’ll bring the band aids so we can start all over when you’re finished “discussing”. 🙂

      1. Ohh i wanna have a go to, ill bring a pair of pliers and a blowtorch .

        Who the hell was thinking , ohh our GPUs has good performance but their power usage is off the charts , i know, lets have 2 processors fight for the same memory buffer and route the result through some mux we let various vendor make a even bigger mess of.

Leave a Reply to Nicola B.Cancel reply