Difference between revisions of "NVIDIA Optimus"

From ArchWiki
Jump to: navigation, search
(Add Category. See Help:Category.)
m (Adding more info on proprietary NVIDIA driver)
(24 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
[[Category:Graphics]]
 
[[Category:Graphics]]
NVIDIA Optimus is a technology where two GPUs are built into a Computer, one is an Intel GPU integrated in the CPU and the other one is a discrete NVIDIA GPU.
+
{{Related articles start}}
 +
{{Related|Bumblebee}}
 +
{{Related|Nouveau}}
 +
{{Related|NVIDIA}}
 +
{{Related articles end}}
  
== Powering on/off the NVIDIA GPU ==
+
NVIDIA Optimus is a technology that allows an Intel integrated GPU and discrete NVIDIA GPU to be built into and accessed by a laptop. Getting Optimus graphics to work on Arch Linux requires a few somewhat complicated steps, explained below. There are several method available:
  
It is recommended to use {{Pkg|bbswitch}} to control the power state of the NVIDIA GPU
+
* disabling 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
To turn it on, do
+
  
# tee /proc/acpi/bbswitch <<< ON
+
* 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
  
note: You will need to unload nouveau/nvidia kernel modules before you can turn off the GPU, e.g.
+
* using the PRIME functionality of the open-source nouveau driver, which allows GPU switching but offers poor performance compared to the proprietary NVIDIA driver and does not currently implement any powersaving
  
# rmmod nouveau
+
* using the third-party Bumblebee program to implement Optimus-like functionality, which offers GPU switching and powersaving but requires extra configuration
# tee /proc/acpi/bbswitch <<< OFF
+
  
== Using NVIDIA Optimus with powersaving ==
+
These options are explained in detail below.
  
See the [[Bumblebee]] article.
+
== Disabling switchable graphics ==
  
== Using NVIDIA Optimus without powersaving ==
+
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 one of the cards. If you want to use both cards, or cannot disable the card you do not want, see the options below.
  
It is possible to offload rendering to the NVIDIA GPU using the features of xrandr 1.4. The disadvantage of this method is that you can't turn off the GPU as long as the X server is running.
+
== Using nvidia ==
  
=== Opensource nouveau driver ===
+
The [[NVIDIA|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. However, it does allow use of the discrete GPU and has (as of October 2013) a marked edge in performance over the nouveau driver.
  
The [[nouveau]] driver fully supports xrandr 1.4. Install {{Pkg|xf86-video-nouveau}} and {{Pkg|xf86-video-intel}}. Remove {{ic|/etc/X11/xorg.conf.d/20-intel.conf}} if it exists. Turn on the GPU and load the nouveau kernel module:
+
First install the modesetting and nvidia drivers:
  
  # modprobe nouveau
+
  # pacman -S xf86-video-modesetting nvidia
  
Now you can start X and it should autodetect your GPUs. You can check that like this:
+
Then install {{ic|xrandr}}:
  
  $ xrandr --listproviders
+
  # pacman -S xorg-xrandr
  
It should give you somethng like this:
+
Next, you must create a custom {{ic|xorg.conf}}. You will need to know the PCI address of the NVIDIA card, which you can find by issuing
  
  Providers: number : 2
+
  $ lspci <nowiki>|</nowiki> grep VGA
Provider 0: id: 0x8a cap: 0xb, Source Output, Sink Output, Sink Offload crtcs: 2 outputs: 2 associated providers: 0 name:Intel
+
Provider 1: id: 0x66 cap: 0x7, Source Output, Sink Output, Source Offload crtcs: 2 outputs: 5 associated providers: 0 name:nouveau
+
  
you can associate the Intel GPU as the offload sink of the NVIDIA one:
+
The PCI address is the first 7 characters of the line that mentions NVIDIA. It will look something like {{ic|01:00.0}}. In the {{ic|xorg.conf}}, you will need to format it as {{ic|#:#:#}}; e.g. {{ic|01:00.0}} would be formatted as {{ic|1:0:0}}. Also, if the NVIDIA card has no display devices attached to it (all video goes through the Intel chip), uncomment the line that reads {{ic|Option "UseDisplayDevice" "none"}}.
  
$ xrandr --setprovideroffloadsink nouveau Intel
+
{{hc|# nano /etc/X11/xorg.conf|
 +
Section "ServerLayout"
 +
    Identifier "layout"
 +
    Screen 0 "nvidia"
 +
    Inactive "intel"
 +
EndSection
  
(you can address the GPUs by id or by name)
+
Section "Device"
 +
    Identifier "nvidia"
 +
    Driver "nvidia"
 +
    BusID "PCI:''PCI address determined earlier''"
 +
    # e.g. BusID "PCI:1:0:0"
 +
EndSection
  
now you can run programs on the NVIDIA GPU like this:
+
Section "Screen"
 +
    Identifier "nvidia"
 +
    Device "nvidia"
 +
    #Option "UseDisplayDevice" "none"
 +
EndSection
  
$ DRI_PRIME=1 glxgears
+
Section "Device"
 +
    Identifier "intel"
 +
    Driver "modesetting"
 +
EndSection
  
=== Official NVIDIA drivers ===
+
Section "Screen"
 +
    Identifier "intel"
 +
    Device "intel"
 +
EndSection}}
  
The official [[NVIDIA]] driver partly supports xrandr 1.4. It does not support the method described above, but it does support setting provider output source.
+
Next, add the following two lines to the beginning of your {{ic|~/.xinitrc}}:
You will have to remove {{Pkg|bumblebee}} as it conflicts with {{Pkg|nvidia-libgl}}. You also need to install {{Pkg|xf86-video-modesetting}} and {{Pkg|nvidia}}.
+
 
Follow the instructions on [ftp://download.nvidia.com/XFree86/Linux-x86_64/319.23/README/randr14.html this website].
+
{{hc|$ nano ~/.xinitrc|
 +
xrandr --setprovideroutputsource modesetting NVIDIA-0
 +
xrandr --auto}}
 +
 
 +
Now reboot to load the drivers, and X should start.
 +
 
 +
If you get a black screen when starting X, make sure that there are no ampersands after the two {{ic|xrandr}} commands in {{ic|~/.xinitrc}}; if there are ampersands, it seems that the window manager can run before the {{ic|xrandr}} commands finish executing, leading to the black screen.
 +
 
 +
You can check if the NVIDIA graphics are being used by installing {{Pkg|mesa-demos}} and running
 +
 
 +
$ glxinfo <nowiki>|</nowiki> grep NVIDIA
 +
 
 +
For more information, look at NVIDIA's official page on the topic [http://http.download.nvidia.com/XFree86/Linux-x86_64/319.23/README/randr14.html here].
 +
 
 +
== Using nouveau ==
 +
 
 +
The open-source [[nouveau]] driver ({{Pkg|xf86-video-nouveau}})can dynamically switch with the Intel driver ({{Pkg|xf86-video-intel}}) 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]].

Revision as of 13:02, 15 December 2013

Related articles

NVIDIA Optimus is a technology that allows an Intel integrated GPU and discrete NVIDIA GPU to be built into and accessed by a laptop. Getting Optimus graphics to work on Arch Linux requires a few somewhat complicated steps, explained below. There are several method available:

  • disabling 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 but offers poor performance compared to the proprietary NVIDIA driver and does not currently implement any powersaving
  • using the third-party Bumblebee program to implement Optimus-like functionality, which offers GPU switching and powersaving but requires extra configuration

These options are explained in detail below.

Disabling switchable graphics

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 one of the cards. If you want to use both cards, or cannot disable the card you do not want, see the options below.

Using nvidia

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. However, it does allow use of the discrete GPU and has (as of October 2013) a marked edge in performance over the nouveau driver.

First install the modesetting and nvidia drivers:

# pacman -S xf86-video-modesetting nvidia

Then install xrandr:

# pacman -S xorg-xrandr

Next, you must create a custom xorg.conf. You will need to know the PCI address of the NVIDIA card, which you can find by issuing

$ lspci | grep VGA

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 #:#:#; e.g. 01:00.0 would be formatted as 1:0:0. Also, if the NVIDIA card has no display devices attached to it (all video goes through the Intel chip), uncomment the line that reads Option "UseDisplayDevice" "none".

# nano /etc/X11/xorg.conf
Section "ServerLayout"
    Identifier "layout"
    Screen 0 "nvidia"
    Inactive "intel"
EndSection

Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
    BusID "PCI:PCI address determined earlier"
    # e.g. BusID "PCI:1:0:0"
EndSection

Section "Screen"
    Identifier "nvidia"
    Device "nvidia"
    #Option "UseDisplayDevice" "none"
EndSection

Section "Device"
    Identifier "intel"
    Driver "modesetting"
EndSection

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

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

$ nano ~/.xinitrc
xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto

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

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 the black screen.

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

$ glxinfo | grep NVIDIA

For more information, look at NVIDIA's official page on the topic here.

Using nouveau

The open-source nouveau driver (xf86-video-nouveau)can dynamically switch with the Intel driver (xf86-video-intel) 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.