Difference between revisions of "NVIDIA Optimus"

From ArchWiki
Jump to: navigation, search
m (change external link to http)
(Removed redundant section, moved Bumblebee section to end of article, added detailed official Optimus information)
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.
+
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 methods.
  
== Powering on/off the NVIDIA GPU ==
+
=== Disabling switchable graphics ===
 +
 
 +
If you only care to use a certain GPU without switching, check your 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 don't want, see the options below.
 +
 
 +
<!-- The information below can all be found in the Bumblebee article, which is mentioned below.
 +
 
 +
== Powering on/off the NVIDIA GPU ==
  
 
It is recommended to use {{Pkg|bbswitch}} to control the power state of the NVIDIA GPU
 
It is recommended to use {{Pkg|bbswitch}} to control the power state of the NVIDIA GPU
Line 12: Line 18:
  
 
  # rmmod nouveau
 
  # rmmod nouveau
  # tee /proc/acpi/bbswitch <<< OFF
+
  # tee /proc/acpi/bbswitch <<< OFF -->
 +
 
 +
=== Using nouveau ===
 +
 
 +
The open-source NVIDIA driver ({{Pkg|xf86-video-nouveau}}), allows for dynamic GPU switching using a technology called PRIME. First, install the Intel and nouveau drivers:
 +
 
 +
{{ic|# pacman -S xf86-video-intel xf86-video-nouveau}}
 +
 
 +
Next, install {{Pkg|xorg-xrandr}}, which allows setting the NVIDIA card as an offload sink of the Intel:
 +
 
 +
{{ic|# pacman -S xorg-xrandr}}
 +
 
 +
Reboot to load the drivers. You should now be able to start X. The next step is to run the following {{ic|xrandr}} command:
 +
 
 +
{{ic|$ xrandr --setprovideroffloadsink nouveau Intel}}
 +
 
 +
You can now run programs with the NVIDIA card by adding {{ic|DRI_PRIME<nowiki>=</nowiki>1 }} before a command; i.e.
 +
 
 +
{{ic|$ DRI_PRIME<nowiki>=</nowiki>1 glxgears}}
 +
 
 +
To check if programs are using the NVIDIA graphics and not Intel, install {{Pkg|mesa-demos}} and run
 +
 
 +
{{ic|$ DRI_PRIME<nowiki>=</nowiki>1 glxinfo | grep nouveau}}
 +
 
 +
You should see a line that says {{ic|OpenGL vendor string: nouveau}}.
  
== Using NVIDIA Optimus with powersaving ==
+
If you don't want to manually run the {{ic|xrandr}} command every time you start X, you can add it at the beginning of your {{ic|~/.xinitrc}}. If you want to run every program using the NVIDIA graphics, you can add the line {{ic|export DRI_PRIME<nowiki>=</nowiki>1}} to your {{ic|~/.bashrc}}.
  
See the [[Bumblebee]] article.
+
=== Using nvidia ===
  
== Using NVIDIA Optimus without powersaving ==
+
The proprietary NVIDIA driver {{Pkg|nvidia}} does not support dynamic switching like the nouveau driver, and has several other disadvantages, but does allow use of the discrete GPU and has (as of October 2013) a marked edge in performance over the nouveau driver. To enable Optimus, you must install the modesetting video driver, the nvidia driver, and xrandr:
  
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.
+
{{ic|# pacman -S xf86-video-modesetting nvidia xorg-xrandr}}
  
=== Opensource nouveau driver ===
+
Next, you must create a custom {{ic|xorg.conf}}. You'll need to know the PCI address of the NVIDIA card, which you can find by issuing
  
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:
+
{{ic|$ lspci | grep VGA}}
  
# modprobe nouveau
+
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'll 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"}}.
  
Now you can start X and it should autodetect your GPUs. You can check that like this:
+
{{hc|# nano /etc/X11/xorg.conf|
 +
Section "ServerLayout"
 +
    Identifier "layout"
 +
    Screen 0 "nvidia"
 +
    Inactive "intel"
 +
EndSection
  
$ xrandr --listproviders
+
Section "Device"
 +
    Identifier "nvidia"
 +
    Driver "nvidia"
 +
    BusID "PCI:''PCI address determined earlier''"
 +
EndSection
  
It should give you somethng like this:
+
Section "Screen"
 +
    Identifier "nvidia"
 +
    Device "nvidia"
 +
    #Option "UseDisplayDevice" "none"
 +
EndSection
  
Providers: number : 2
+
Section "Device"
Provider 0: id: 0x8a cap: 0xb, Source Output, Sink Output, Sink Offload crtcs: 2 outputs: 2 associated providers: 0 name:Intel
+
    Identifier "intel"
Provider 1: id: 0x66 cap: 0x7, Source Output, Sink Output, Source Offload crtcs: 2 outputs: 5 associated providers: 0 name:nouveau
+
    Driver "modesetting"
 +
EndSection
  
you can associate the Intel GPU as the offload sink of the NVIDIA one:
+
Section "Screen"
 +
    Identifier "intel"
 +
    Device "intel"
 +
EndSection}}
  
$ xrandr --setprovideroffloadsink nouveau Intel
+
Next, add the following two lines to the beginning of your {{ic|~/.xinitrc}}:
  
(you can address the GPUs by id or by name)
+
{{hc|$ nano .xinitrc|
 +
xrandr --setprovideroutputsource modesetting NVIDIA-0
 +
xrandr --auto}}
  
now you can run programs on the NVIDIA GPU like this:
+
Now reboot to load the drivers, and X should start. If you get a black screen, make sure that there are no ampersands after the two {{ic|xrandr}} command in {{ic|~/.xinitrc}}; if there are ampersands, it appears that the window manager is run before the command finish executing, leading to the black screen.
  
$ DRI_PRIME=1 glxgears
+
As with the nouveau drivers, you can check if the NVIDIA graphics are being used by install {{Pkg|mesa-demos}} and running
  
=== Official NVIDIA drivers ===
+
{{ic|$ glxinfo | grep NVIDIA}}.
  
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.
+
http://http.download.nvidia.com/XFree86/Linux-x86_64/319.23/README/randr14.html
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 in [http://http.download.nvidia.com/XFree86/Linux-x86_64/319.23/README/randr14.html README/randr14.html (nvidia.com)].
 

Revision as of 02:37, 21 October 2013

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 methods.

Disabling switchable graphics

If you only care to use a certain GPU without switching, check your 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 don't want, see the options below.


Using nouveau

The open-source NVIDIA driver (xf86-video-nouveau), allows for dynamic GPU switching using a technology called PRIME. First, install the Intel and nouveau drivers:

# pacman -S xf86-video-intel xf86-video-nouveau

Next, install xorg-xrandr, which allows setting the NVIDIA card as an offload sink of the Intel:

# pacman -S xorg-xrandr

Reboot to load the drivers. You should now be able to start X. The next step is to run the following xrandr command:

$ xrandr --setprovideroffloadsink nouveau Intel

You can now run programs with the NVIDIA card by adding DRI_PRIME=1 before a command; i.e.

$ DRI_PRIME=1 glxgears

To check if programs are using the NVIDIA graphics and not Intel, install mesa-demos and run

$ DRI_PRIME=1 glxinfo

You should see a line that says OpenGL vendor string: nouveau.

If you don't want to manually run the xrandr command every time you start X, you can add it at the beginning of your ~/.xinitrc. If you want to run every program using the NVIDIA graphics, you can add the line export DRI_PRIME=1 to your ~/.bashrc.

Using nvidia

The proprietary NVIDIA driver nvidia does not support dynamic switching like the nouveau driver, and has several other disadvantages, but does allow use of the discrete GPU and has (as of October 2013) a marked edge in performance over the nouveau driver. To enable Optimus, you must install the modesetting video driver, the nvidia driver, and xrandr:

# pacman -S xf86-video-modesetting nvidia xorg-xrandr

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

$ lspci

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'll 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"
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, make sure that there are no ampersands after the two xrandr command in ~/.xinitrc; if there are ampersands, it appears that the window manager is run before the command finish executing, leading to the black screen.

As with the nouveau drivers, you can check if the NVIDIA graphics are being used by install mesa-demos and running

$ glxinfo .

http://http.download.nvidia.com/XFree86/Linux-x86_64/319.23/README/randr14.html