Nvidia-xrun

From ArchWiki
Jump to navigation Jump to search

Nvidia-xrun is a utility to allow Nvidia optimus enabled laptops run X server with discrete nvidia graphics on demand. This solution offers full GPU utilization, compatibility and better performance than Bumblebee.

X server can only be used with integrated graphics or discrete Nvidia graphics, but not both, so user might want to switch to separate virtual console and start another X server using different graphics from what was used for the first X server.

Installation

Install:

Configuration

Setting the right bus id

Note: Users who installed nvidia-xrun from the AUR can skip this step, because the bus id has been automatically set in /etc/X11/nvidia-xorg.conf.

Find your display device bus id:

 $ lspci | grep -i nvidia | awk '{print $1}'

It might return something similar to 01:00.0. Then create a script (for example /etc/X11/nvidia-xorg.conf.d/30-nvidia.conf) to set the proper bus id:

/etc/X11/nvidia-xorg.conf.d/30-nvidia.conf
Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
    BusID "PCI:1:0:0"
EndSection

Also this way you can adjust some nvidia settings if you encounter issues:

/etc/X11/nvidia-xorg.conf.d/30-nvidia.conf
Section "Screen"
    Identifier "nvidia"
    Device "nvidia"
    #  Option "AllowEmptyInitialConfiguration" "Yes"
    #  Option "UseDisplayDevice" "none"
EndSection

Automatically run window manager

For convenience you can create an ~/.nvidia-xinitrc file with your favourite window manager:

openbox-session

With it you do not need to specify the app and can simply execute:

$ nvidia-xrun

Use bbswitch to manage nvidia

When the nvidia card is not needed, bbswitch can be used to turn it off. The nvidia-xrun script will automatically take care of running a window manager and waking up the nvidia card. To achieve that, you need to:

  • Load bbswitch module on boot
 # echo 'bbswitch ' > /etc/modules-load.d/bbswitch.conf
  • Disable the nvidia module on boot:
 # echo 'options bbswitch load_state=0 unload_state=1' > /etc/modprobe.d/bbswitch.conf 

After a reboot, the nvidia card will be off. This can be seen by querying bbswitch's status:

 $ cat /proc/acpi/bbswitch  

To force the card to turn on/off respectively run:

 # tee /proc/acpi/bbswitch <<<OFF
 # tee /proc/acpi/bbswitch <<<ON

For more about bbswitch see Bumblebee-Project/bbswitch.

Usage

Once system boots, from virtual console login to your user and run nvidia-xrun <application>.

If above does not work, switch to unused virtual console and try again.

Troubleshooting

General issues

Running apps directly with nvidia-xrun <application> does not work well. Use window manager like openbox and run apps from it.

Issues with Nvidia after removing Bumblebee

See #Use bbswitch to manage nvidia.

If Nvidia GPU still fails to switch off, or is somehow set to be default whenever you use or not nvidia-xrun, then you might likely need to blacklist specific modules (which were previously blacklisted by Bumblebee). Create this file and restart your system:

/usr/lib/modprobe.d/nvidia-xrun.conf
blacklist nvidia
blacklist nvidia-drm
blacklist nvidia-modeset
blacklist nvidia-uv
blacklist nvidia_uvm
blacklist nouveau

Make sure DRM kernel mode setting is disabled see NVIDIA#DRM kernel mode setting