Difference between revisions of "Nvidia-xrun"

From ArchWiki
Jump to navigation Jump to search
(Fix style. See Help:Style.)
m (Convert value from hex in lspci to decimal for xorg config. This is the only way some people, including myself, can get it to work.)
 
(39 intermediate revisions by 18 users not shown)
Line 1: Line 1:
 
[[Category:Graphics]]
 
[[Category:Graphics]]
[[zh-hans:nvidia-xrun]]
+
[[ja:Nvidia-xrun]]
[https://github.com/Witko/nvidia-xrun nvidia-xrun] is a utility to run separate X with discrete nvidia graphics. This solution offers a bit more complicated procedure but offers a full GPU utilization(in terms of linux drivers).
+
[[ru:Nvidia-xrun]]
 +
[[zh-hans:Nvidia-xrun]]
 +
[https://github.com/Witko/nvidia-xrun 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]].
  
== installation ==
+
X server can only be used with integrated graphics or discrete Nvidia graphics, but not both, so user might want to switch to separate [[Linux_console|virtual console]] and start another X server using different graphics from what was used for the first X server.
 +
 
 +
== Installation ==
 +
{{Out of date|As of [https://github.com/Witko/nvidia-xrun/issues/109 nvidia-xrun release 0.4], the PM fork has been merged and bbswitch is no longer used. There may be changes to AUR packages and bbswitch configuration}}
 
[[Install]]:
 
[[Install]]:
 
* {{Pkg|nvidia}}
 
* {{Pkg|nvidia}}
 
* {{Pkg|bbswitch}}
 
* {{Pkg|bbswitch}}
* {{AUR|nvidia-xrun}} or {{AUR|nvidia-xrun-git}}
+
* {{AUR|nvidia-xrun}}, {{AUR|nvidia-xrun-git}},
* a [[Window manager]], such as {{Pkg|openbox}} it only for running applications,becasue running some applications (such as Steam) directly with nvidia-xrun does not work well, use some window manager like openbox will be better.
+
** or {{AUR|nvidia-xrun-pm}} if bbswitch doesn't support your hardware (see [https://bbs.archlinux.org/viewtopic.php?id=238389])
== configuration ==
+
* a [[Window manager]], such as {{Pkg|openbox}} or {{Pkg|xfce4-session}},because running apps directly with {{ic|nvidia-xrun <application>}} does not work well.
 +
 
 +
== Configuration ==
 
=== Setting the right bus id ===
 
=== Setting the right bus id ===
If you install nvidia-xrun from [[AUR]],you can skip this step,the bus id has been already setted in {{ic|/etc/X11/nvidia-xorg.conf}}
 
  
If you down nvidia-xrun form [nvidia-xrun github repo],perhaps you should set the bus id.
+
{{Note|If you installed package from [[AUR]], the bus id has been automatically set in {{ic|/etc/X11/nvidia-xorg.conf}}. Make sure the bus ID has been correctly set, otherwise change it (you can find correct bus ID using {{ic|lspci}} command). In some cases you need to convert the hex output from {{ic|lspci}} to decimal for nvidia-xorg.conf, e.g. 3b:00.0 becomes "PCI:59:0:0"}}
  
check your display device's bus id
+
Find your display device bus id:
   $ lspci | grep NVIDIA
+
   $ lspci | grep -i nvidia | awk '{print $1}'
  
You will find your bus id.Usually the 1:0:0 bus is correct. If this is not your case(you can find out through lspci or bbswitch output mesages) you can create a conf script for example nano /etc/X11/nvidia-xorg.conf.d/30-nvidia.conf to set the proper bus id:
+
It might return something similar to '''{{ic|01:00.0}}'''. Then create a file (for example {{ic|/etc/X11/nvidia-xorg.conf.d/30-nvidia.conf}}) to set the proper bus id:
  
 
{{hc|/etc/X11/nvidia-xorg.conf.d/30-nvidia.conf|
 
{{hc|/etc/X11/nvidia-xorg.conf.d/30-nvidia.conf|
Line 24: Line 30:
 
     Identifier "nvidia"
 
     Identifier "nvidia"
 
     Driver "nvidia"
 
     Driver "nvidia"
     BusID "PCI:2:0:0"
+
     BusID "PCI:'''1:0:0'''"
 
EndSection}}
 
EndSection}}
  
Line 39: Line 45:
 
=== Automatically run window manager ===
 
=== Automatically run window manager ===
  
For convenience you can create nano ~/.nvidia-xinitrc and put there your favourite window manager:
+
For convenience you can create an {{ic|~/.nvidia-xinitrc}} file with your favourite window manager.
  
  openbox-session
+
if [ $# -gt 0 ]; then
 +
  $*
 +
else
 +
  openbox-session
 +
  # Alternatively, you can also use xfce4:
 +
  # xfce4-session
 +
fi
  
With this you do not need to specify the app and you can simply run:
+
With it you do not need to specify the app and can simply execute:
  
  nvidia-xrun
+
$ nvidia-xrun
  
 
=== Use bbswitch to manage nvidia ===
 
=== Use bbswitch to manage nvidia ===
When do not need to use nvidia , use bbswitch to turn off it , and run application which need nvidia , nvidia-xrun will automatically run window manager and wake up 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 when boot
 
  # echo 'bbswitch ' > /etc/modules-load.d/bbswitch
 
 
 
* Disable the nvidia on boot time.
 
  # echo 'options bbswitch load_state=0' > /etc/modprobe.d/bbswitch.conf
 
  
* Blacklisting nvidia modules
+
* Load bbswitch module on boot
 +
  # echo 'bbswitch ' > /etc/modules-load.d/bbswitch.conf
  
$ lsmod | grep nvidia | cut -d ' ' -f 1 > /tmp/nvidia
+
* Disable the nvidia module on boot:
$ lsmod | grep  nouveau | cut -d ' ' -f 1 > > /tmp/nvidia
+
  # echo 'options bbswitch load_state=0 unload_state=1' > /etc/modprobe.d/bbswitch.conf  
$ sort -n /tmp/nvidia | uniq > /tmp/nvidia.conf
 
$ sed -i 's/^\w*$/blacklist &/g' /tmp/nvidia.conf
 
# cp /tmp/nvidia.conf /etc/modprobe.d/nvidia.conf
 
  
Reboot system , nvidia will be off , you can geet the status:
+
After a reboot, the nvidia card will be off. This can be seen by querying bbswitch's status:
  
 
   $ cat /proc/acpi/bbswitch   
 
   $ cat /proc/acpi/bbswitch   
  
turn the card off, respectively on:
+
To force the card to turn on/off respectively run:
  
 
   # tee /proc/acpi/bbswitch <<<OFF
 
   # tee /proc/acpi/bbswitch <<<OFF
 
   # tee /proc/acpi/bbswitch <<<ON
 
   # tee /proc/acpi/bbswitch <<<ON
  
more about bbswitch see [https://github.com/Bumblebee-Project/bbswitch Bumblebee-Project/bbswitch]
+
For more about bbswitch see [https://github.com/Bumblebee-Project/bbswitch Bumblebee-Project/bbswitch].
 +
 
 +
== Usage ==
 +
 
 +
Once the system boots, from the virtual console, login to your user, and run {{ic|nvidia-xrun <application>}}.
 +
 
 +
If above does not work, [[Keyboard_shortcuts#Xorg_and_Wayland|switch]] to unused virtual console and try again.
  
== usage ==
+
As mentioned before, running apps directly with {{ic|nvidia-xrun <application>}} '''does not work well''', so it is best to create an {{ic|~/.nvidia-xinitrc}} as outlined earlier, and use {{ic|nvidia-xrun}} to launch your window manager.
#switch to free tty
 
#login
 
#run {{ic|nvidia-xrun [app]}}
 
  
 
== Troubleshooting ==
 
== Troubleshooting ==
Running Steam directly with nvidia-xrun does not work well, use some window manager like openbox will be better.
+
 
 +
=== NVIDIA GPU fails to switch off or is set to be default  ===
 +
 
 +
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 {{ic|nvidia-xrun}}, then you might likely need to blacklist specific modules (which were previously blacklisted by [[Bumblebee]]). Create this file and restart your system:
 +
 
 +
{{hc|/usr/lib/modprobe.d/nvidia-xrun.conf|
 +
blacklist nvidia
 +
blacklist nvidia-drm
 +
blacklist nvidia-modeset
 +
blacklist nvidia-uvm
 +
blacklist nouveau
 +
}}
 +
 
 +
Make sure DRM kernel mode setting is disabled see [[NVIDIA#DRM kernel mode setting]]

Latest revision as of 07:47, 19 September 2019

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

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: As of nvidia-xrun release 0.4, the PM fork has been merged and bbswitch is no longer used. There may be changes to AUR packages and bbswitch configuration (Discuss in Talk:Nvidia-xrun#)

Install:

Configuration

Setting the right bus id

Note: If you installed package from AUR, the bus id has been automatically set in /etc/X11/nvidia-xorg.conf. Make sure the bus ID has been correctly set, otherwise change it (you can find correct bus ID using lspci command). In some cases you need to convert the hex output from lspci to decimal for nvidia-xorg.conf, e.g. 3b:00.0 becomes "PCI:59:0:0"

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 file (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.

if [ $# -gt 0 ]; then
  $*
else
  openbox-session
  # Alternatively, you can also use xfce4:
  # xfce4-session
fi

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 the system boots, from the virtual console, login to your user, and run nvidia-xrun <application>.

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

As mentioned before, running apps directly with nvidia-xrun <application> does not work well, so it is best to create an ~/.nvidia-xinitrc as outlined earlier, and use nvidia-xrun to launch your window manager.

Troubleshooting

NVIDIA GPU fails to switch off or is set to be default

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-uvm
blacklist nouveau

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