pedro00dk / nvidia-exec

GPU switching without login out for Nvidia Optimus laptops under Linux
https://aur.archlinux.org/packages/nvidia-exec
GNU General Public License v3.0
129 stars 9 forks source link

"nvx on" seems to not enable NVIDIA GPU #37

Open D3vil0p3r opened 11 months ago

D3vil0p3r commented 11 months ago

I have an hybrid scenario with iGPU Intel and NVIDIA GPU. My environment is Arch Linux with Cinnamon (x11). GPUs are both recognized by the system:

lspci | grep VGA

00:02.0 VGA compatible controller: Intel Corporation CoffeeLake-H GT2 [UHD Graphics 630]
01:00.0 VGA compatible controller: NVIDIA Corporation TU106M [GeForce RTX 2060 Mobile] (rev a1)

and my system starts always by iGPU, indeed:

glxinfo | grep "OpenGL render"

OpenGL renderer string: Mesa Intel(R) UHD Graphics 630 (CFL GT2)

If I run nvx on I get:

# turn on gpu
-- pci rescan
-- pci "PCI bridge - 6th-10th Gen Core Processor PCIe Controller (x16)" -> 0000:00:01.0
   -- pci power control on
   -- device enable "VGA compatible controller - TU106M [GeForce RTX 2060 Mobile]" -> 0000:01:00.0
# load modules
   -- module nvidia
   -- module nvidia_uvm
   -- module nvidia_modeset
   -- module nvidia_drm

but when I reboot and I run glxinfo | grep "OpenGL render", I still get:

OpenGL renderer string: Mesa Intel(R) UHD Graphics 630 (CFL GT2)

instead of NVIDIA.

Then, I also noted that, when I run nvx start ", during the off part it freezes, and if I close the current terminal and open a new one and run nvx off-kill**, I get:

# kill processes
-- no processes found
# unload modules
-- module nvidia_drm
-- module nvidia_modeset
-- module nvidia_uvm
-- module nvidia
# turn off
-- pci "PCI bridge - 6th-10th Gen Core Processor PCIe Controller (x16)" -> 0000:00:01.0
   -- device remove "VGA compatible controller - TU106M [GeForce RTX 2060 Mobile]" -> 0000:01:00.0
tee: '/sys/bus/pci/devices/0000:01:00.0/remove': Permission denied
   -- power control auto

but nvx status returns:

on

I already followed the guidebin README about this but with no luck.

ia74 commented 3 months ago

you have to do nvx start glxinfo | grep "OpenGL render". for context, this will:

or you can add these env variables to the beginning of your command, to skip using nvx start. do keep in mind you still have to use nvx on to turn your gpu on.

__NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only __GLX_VENDOR_LIBRARY_NAME=nvidia

so your command would look like:

__NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo | grep "OpenGL render"

this is because your gpu isnt set as the default renderer (which, this is the correct setup), and the system needs to be told that it needs to offload the command to the gpu.

just incase you aren't sold yet, here's my output. keep in mind my nvidia gpu is already on with nvx on.

[aiden@archtop ~]$ glxinfo | grep "OpenGL render"
OpenGL renderer string: Mesa Intel(R) Graphics (RPL-P)
[aiden@archtop ~]$ __NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo | grep "OpenGL render"
OpenGL renderer string: NVIDIA GeForce RTX 4060 Laptop GPU/PCIe/SSE2