NVIDIA Optimus

From ArchWiki
Revision as of 11:32, 17 August 2019 by Erkexzcx (talk | contribs) (→‎Using nvidia: Changed title to "Use Nvidia graphics only")
Jump to navigation Jump to search

Nvidia optimus is a technology that allows an Intel integrated GPU and discrete NVIDIA GPU to be built into and accessed by a laptop.

Available methods

There are several methods available:

  • Disable one of the devices in BIOS, which may result in improved battery life if the NVIDIA device is disabled, but may not be available with all BIOSes and does not allow GPU switching
  • using the official Optimus support included with the proprietary NVIDIA driver, which offers the best NVIDIA performance but does not allow GPU switching and can be more buggy than the open-source driver
  • using the PRIME functionality of the open-source nouveau driver, which allows GPU switching and powersaving but offers poor performance compared to the proprietary NVIDIA driver and may cause issues with sleep and hibernate
  • using the third-party Bumblebee program to implement Optimus-like functionality, which offers GPU switching and powersaving but requires extra configuration
  • using the nvidia-xrun utility to run separate X sessions with discrete nvidia graphics with full performance

Use Intel graphics only

If you only care to use a certain GPU without switching, check the options in your system's BIOS. There should be an option to disable one of the cards. Some laptops only allow disabling of the discrete card, or vice-versa, but it is worth checking if you only plan to use just one of the cards.

If your BIOS does not allow to disable Nvidia graphics, you can disable it from the Linux itself. See Hybrid graphics#Fully Power Down Discrete GPU.

Use Nvidia graphics only

The proprietary NVIDIA driver does not support dynamic switching like the nouveau driver (meaning it can only use the NVIDIA device). It also has notable screen-tearing issues that NVIDIA recognizes but has not fixed, unless you are using x.org > 1.19 and enable prime sync, see [1]. However, it does allow use of the discrete GPU and has (as of January 2017) a marked edge in performance over the nouveau driver.

First, install the NVIDIA driver and xorg-xrandr. Then, configure xorg.conf. You will need to know the PCI address of the NVIDIA card, which you can find by issuing

$ lspci | egrep 'VGA|3D'

The PCI address is the first 7 characters of the line that mentions NVIDIA. It will look something like 01:00.0. In the xorg.conf, you will need to format it as #:#:# while converting hexadecimal numbers to decimal numbers; e.g. 01:00.0 would be formatted as 1:0:0.

Note: On some setups this setup breaks automatic detection of the values of the display by the nvidia driver through the EDID file. As a work-around see #Resolution, screen scan wrong. EDID errors in Xorg.log.

If X.Org X server version 1.17.2 or higher is installed ([2])

Section "Module"
    Load "modesetting"

Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
    BusID "PCI:<BusID for NVIDIA device here>"
    Option "AllowEmptyInitialConfiguration"

Next, add the following two lines to the beginning of your ~/.xinitrc:

xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto

Now reboot to load the drivers, and X should start.

If your display dpi is not correct add the following line:

xrandr --dpi 96

If you get a black screen when starting X, make sure that there are no ampersands after the two xrandr commands in ~/.xinitrc. If there are ampersands, it seems that the window manager can run before the xrandr commands finish executing, leading to a black screen.

Display Managers

If you are using a display manager then you will need to create or edit a display setup script for your display manager instead of using ~/.xinitrc.


For the LightDM display manager:

xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto

Make the script executable:

# chmod +x /etc/lightdm/display_setup.sh

Now configure lightdm to run the script by editing the [Seat:*] section in /etc/lightdm/lightdm.conf:


Now reboot and your display manager should start.


For the SDDM display manager (SDDM is the default DM for KDE):

xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto


For the GDM display manager create two new .desktop files:

[Desktop Entry]
Exec=sh -c "xrandr --setprovideroutputsource modesetting NVIDIA-0; xrandr --auto"

Make sure that GDM use X as default backend.

Checking 3D

You can check if the NVIDIA graphics are being used by installing mesa-demos and running

$ glxinfo | grep NVIDIA

Further Information

For more information, look at NVIDIA's official page on the topic [3].


Tearing/Broken VSync

This requires xorg-server 1.19 or higher, linux kernel 4.5 or higher, and nvidia 370.23 or higher. Then enable DRM kernel mode setting, which will in turn enable the PRIME synchronization and fix the tearing.

You can read the official forum thread for details.

Failed to initialize the NVIDIA GPU at PCI:1:0:0 (GPU fallen off the bus / RmInitAdapter failed!)

Add rcutree.rcu_idle_gp_delay=1 to the kernel parameters. Original topic can be found in [4] and [5].

Resolution, screen scan wrong. EDID errors in Xorg.log

This is due to the NVIDIA driver not detecting the EDID for the display. You need to manually specify the path to an EDID file or provide the same information in a similar way.

To provide the path to the EDID file edit the Device Section for the NVIDIA card in Xorg.conf, adding these lines and changing parts to reflect your own system:

Section "Device"
       	Option		"ConnectedMonitor" "CRT-0"
       	Option		"CustomEDID" "CRT-0:/sys/class/drm/card0-LVDS-1/edid"
	Option		"IgnoreEDID" "false"
	Option		"UseEDID" "true"

If Xorg wont start try swapping out all references of CRT to DFB. card0 is the identifier for the intel card to which the display is connected via LVDS. The edid binary is in this directory. If the hardware arrangement is different, the value for CustomEDID might vary but yet this has to be confirmed. The path will start in any case with /sys/class/drm.

Alternatively you can generate your edid with tools like read-edid and point the driver to this file. Even modelines can be used, but then be sure to change "UseEDID" and "IgnoreEDID".

Wrong resolution without EDID errors

Using nvidia-xconfig, incorrect information might be generated in Xorg.conf and in particular wrong monitor refresh rates that restruct the possible resolutions. Try commenting out the HorizSync/VertRefresh lines. If this helps, you can probably also remove everything else not mentioned in this article.

Lockup issue (lspci hangs)

Symptoms: lspci hangs, system suspend fails, shutdown hangs, optirun hangs.

Applies to: newer laptops with GTX 965M or alike when bbswitch (e.g. via Bumblebee) or nouveau is in use.

When the dGPU power resource is turned on, it may fail to do so and hang in ACPI code (kernel bug 156341).

For known model-specific workarounds, see this issue. In other cases you can try to boot with acpi_osi="!Windows 2015" or acpi_osi=! acpi_osi="Windows 2009" added to your Kernel parameters. (Consider reporting your laptop to that issue.)

No screens found on a laptop/NVIDIA Optimus

Check if $ lspci | grep VGA outputs something similar to:

00:02.0 VGA compatible controller: Intel Corporation Core Processor Integrated Graphics Controller (rev 02)
01:00.0 VGA compatible controller: nVidia Corporation Device 0df4 (rev a1)

NVIDIA drivers now offer Optimus support since 319.12 Beta [6] with kernels above and including 3.9.

Another solution is to install the Intel driver to handle the screens, then if you want 3D software you should run them through Bumblebee to tell them to use the NVIDIA card.

Using nouveau

The open-source nouveau driver can dynamically switch with the Intel graphics driver using a technology called PRIME. For more information, see the wiki article on PRIME.

Using Bumblebee

If you wish to use Bumblebee, which will implement powersaving and some other useful features, see the wiki article on Bumblebee.

Using nvidia-xrun

See nvidia-xrun.

Using optimus-manager

Optimus-manager allows easily switch your graphics with a click of the button. Install optimus-managerAUR and optimus-manager-qtAUR, reboot and start applet from your start menu. Right click on it and choose which graphics to use.