bayasdev / envycontrol

Easy GPU switching for Nvidia Optimus laptops under Linux
https://bayas.dev/envycontrol
MIT License
1.18k stars 60 forks source link

Envycontrol won't work in a muxless optimus laptop #86

Closed Juhayer-Al-Wasif closed 1 year ago

Juhayer-Al-Wasif commented 1 year ago

I have an HP-Envy laptop that will go blank screen when I switch to Nvidia-only mode in Envycontrol. Here's Why:

 neofetch
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢰⡆⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄  wasif@hpenvylaptop14eb0xxx
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢠⣿⣿⡄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄  
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣾⣿⣿⣿⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄    · Archcraft x86_64
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⣼⣿⣿⣿⣿⣷⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄    · HP ENVY Laptop 14-eb0xxx
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⣼⣿⣿⣿⣿⣿⣿⣷⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄    · 6.2.1-arch1-1
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢼⣿⣿⣿⣿⣿⣿⣿⣿⣧⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄    · 56 secs
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⣰⣤⣈⠻⢿⣿⣿⣿⣿⣿⣿⣧⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄    · 1132 (pacman)
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⣰⣿⣿⣿⣿⣮⣿⣿⣿⣿⣿⣿⣿⣧⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄    · zsh 5.9
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄    · 1920x1200
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄    · bspwm
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄    · Arc-Dark [GTK2/3]
⠄⠄⠄⠄⠄⠄⠄⠄⠄⣼⣿⣿⣿⣿⣿⡿⣿⣿⡟⠄⠄⠸⣿⣿⡿⣿⣿⣿⣿⣿⣷⡀⠄⠄⠄⠄⠄⠄⠄⠄    · Arc-Circle [GTK2/3]
⠄⠄⠄⠄⠄⠄⠄⠄⣼⣿⣿⣿⣿⣿⡏⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠈⣿⣿⣿⣿⣿⣷⡀⠄⠄⠄⠄⠄⠄⠄    · alacritty
⠄⠄⠄⠄⠄⠄⢀⣼⣿⣿⣿⣿⣿⣿⡗⠄⠄⠄⢀⣠⣤⣀⠄⠄⠄⠸⣿⣿⣿⣿⣿⣿⣷⡀⠄⠄⠄⠄⠄⠄    · 11th Gen Intel i5-1135G7 (8) @ 4.200GHz
⠄⠄⠄⠄⠄⢀⣾⣿⣿⣿⣿⣿⡏⠁⠄⠄⠄⢠⣿⣿⣿⣿⡇⠄⠄⠄⠄⢙⣿⣿⣻⠿⣿⣷⡀⠄⠄⠄⠄⠄    · NVIDIA GeForce GTX 1650 Ti Mobile
⠄⠄⠄⠄⢀⣾⣿⣿⣿⣿⣿⣿⣷⣤⡀⠄⠄⠄⠻⣿⣿⡿⠃⠄⠄⠄⢀⣼⣿⣿⣿⣿⣦⣌⠙⠄⠄⠄⠄⠄    · Intel TigerLake-LP GT2 [Iris Xe Graphics]
⠄⠄⠄⢠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡀⠄⠄⠄    · 734MiB / 15749MiB
⠄⠄⢠⣿⣿⣿⣿⣿⣿⣿⡿⠟⠋⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠙⠻⣿⣿⣿⣿⣿⣿⣿⣿⡄⠄⠄
⠄⣠⣿⣿⣿⣿⠿⠛⠋⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠉⠙⠻⢿⣿⣿⣿⣿⣆⠄
⡰⠟⠛⠉⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠉⠙⠛⠿⢆
lspci
0000:00:00.0 Host bridge: Intel Corporation 11th Gen Core Processor Host Bridge/DRAM Registers (rev 01)
0000:00:02.0 VGA compatible controller: Intel Corporation TigerLake-LP GT2 [Iris Xe Graphics] (rev 01)
0000:00:06.0 PCI bridge: Intel Corporation 11th Gen Core Processor PCIe Controller (rev 01)
0000:00:07.0 PCI bridge: Intel Corporation Tiger Lake-LP Thunderbolt 4 PCI Express Root Port #0 (rev 01)
0000:00:08.0 System peripheral: Intel Corporation GNA Scoring Accelerator module (rev 01)
0000:00:0d.0 USB controller: Intel Corporation Tiger Lake-LP Thunderbolt 4 USB Controller (rev 01)
0000:00:0d.2 USB controller: Intel Corporation Tiger Lake-LP Thunderbolt 4 NHI #0 (rev 01)
0000:00:0e.0 RAID bus controller: Intel Corporation Volume Management Device NVMe RAID Controller
0000:00:14.0 USB controller: Intel Corporation Tiger Lake-LP USB 3.2 Gen 2x1 xHCI Host Controller (rev 20)
0000:00:14.2 RAM memory: Intel Corporation Tiger Lake-LP Shared SRAM (rev 20)
0000:00:14.3 Network controller: Intel Corporation Wi-Fi 6 AX201 (rev 20)
0000:00:15.0 Serial bus controller: Intel Corporation Tiger Lake-LP Serial IO I2C Controller #0 (rev 20)
0000:00:15.1 Serial bus controller: Intel Corporation Tiger Lake-LP Serial IO I2C Controller #1 (rev 20)
0000:00:16.0 Communication controller: Intel Corporation Tiger Lake-LP Management Engine Interface (rev 20)
0000:00:1c.0 PCI bridge: Intel Corporation Device a0be (rev 20)
0000:00:1d.0 System peripheral: Intel Corporation RST VMD Managed Controller
0000:00:1e.0 Communication controller: Intel Corporation Tiger Lake-LP Serial IO UART Controller #0 (rev 20)
0000:00:1e.3 Serial bus controller: Intel Corporation Tiger Lake-LP Serial IO SPI Controller #1 (rev 20)
0000:00:1f.0 ISA bridge: Intel Corporation Tiger Lake-LP LPC Controller (rev 20)
0000:00:1f.3 Multimedia audio controller: Intel Corporation Tiger Lake-LP Smart Sound Technology Audio Controller (rev 20)
0000:00:1f.4 SMBus: Intel Corporation Tiger Lake-LP SMBus Controller (rev 20)
0000:00:1f.5 Serial bus controller: Intel Corporation Tiger Lake-LP SPI Controller (rev 20)
0000:01:00.0 3D controller: NVIDIA Corporation TU117M [GeForce GTX 1650 Ti Mobile] (rev a1)
0000:2c:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS522A PCI Express Card Reader (rev 01)
10000:e0:1d.0 PCI bridge: Intel Corporation Tiger Lake-LP PCI Express Root Port #9 (rev 20)
10000:e1:00.0 Non-Volatile memory controller: Toshiba Corporation XG6 NVMe SSD Controller

A muxless Nvidia Optimus laptop is a laptop that has both an integrated GPU (usually Intel) and a discrete GPU (Nvidia) but does not have a hardware multiplexer (mux) to switch between them. Instead, the integrated GPU drives the internal display create the discrete GPU can only be used for rendering tasks.

This means that the X server (the graphical interface for Linux systems) should not be configured to use the Nvidia X driver after installing it, as this would cause conflicts and errors. Instead, users can use tools like Bumblebee or PRIME to manage which applications use the discrete GPU.

Some laptops have a mux that allows switching between integrated and discrete GPUs, but this requires rebooting or logging out. Some laptops also have an additional mux chip added by the manufacturer that can switch between GPUs without rebooting. However, these are not standard features and are not supported by Nvidia.

Source: (1) Chapter 17. Using the NVIDIA Driver with Optimus Laptops. https://download.nvidia.com/XFree86/Linux-x86_64/455.28/README/optimus.html

(2) Chapter 17. Using the NVIDIA Driver with Optimus Laptops. https://download.nvidia.com/XFree86/Linux-x86_64/455.28/README/optimus.html

(3) How to know if the laptop is MUXed or MUXless: r/VFIO - Reddit. https://www.reddit.com/r/VFIO/comments/j64vkx/how_to_know_if_laptop_is_muxed_or_muxless/

(4) Chapter 17. Using the NVIDIA Driver with Optimus Laptops. https://download.nvidia.com/XFree86/Linux-x86/384.59/README/optimus.html

(5) [GUIDE] Optimus laptop dGPU passthrough · GitHub - Gist. https://gist.github.com/Misairu-G/616f7b2756c488148b7309addc940b28

(6) Intel and NVIDIA GPU Passthrough on an Optimus MUXless Laptop. https://lantian.pub/en/article/modify-computer/laptop-intel-nvidia-optimus-passthrough.lantian/

bayasdev commented 1 year ago

Hello there, Envycontrol should work fine despite your laptop doesn't have any video output wired to the dGPU (that's why lspci identifies it as a 3D controller instead of VGA).

I can see you're using bspwm so you need to manually setup your display manager or whatever else to run the following commands at startup:

https://github.com/bayasdev/envycontrol/wiki/Frequently-Asked-Questions#what-to-do-if-my-display-manager-is-not-supported

Doing that will fix your black screen problem on Nvidia mode.

Juhayer-Al-Wasif commented 1 year ago

Not only bspwm but also I've tried it in Manjaro Plasma & Gnome, seems like for my device the only solution is Prime render offload and Bumblebee Switch.

bayasdev commented 1 year ago

Not only bspwm but also I've tried it in Manjaro KDE, seems like for my device the only solution is Prime render offload and Bumblebee Switch.

That's an interesting case, what does the xrandr --listproviders command outputs?

Juhayer-Al-Wasif commented 1 year ago
Providers: number : 2
Provider 0: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 4 outputs: 4 associated providers: 0 name:modesetting
Provider 1: id: 0x244 cap: 0x0 crtcs: 0 outputs: 0 associated providers: 0 name:NVIDIA-G0
bayasdev commented 1 year ago

@Juhayer-Al-Wasif can you try the latest changes from the rewrite-pci branch?

Thank you!

Juhayer-Al-Wasif commented 1 year ago

do I just have to install the latest release?

bayasdev commented 1 year ago

do I just have to install the latest release?

No, please clone the repository and run the following commands:

git checkout rewrite-pci
sudo python ./envycontrol.py -s nvidia
bayasdev commented 1 year ago

@Juhayer-Al-Wasif if you have problems following the steps, here's the link to the updated file.

Download and run it from your terminal.

gaming128 commented 1 year ago

this is odd, i also use a muxless laptop (HP victus 16z-e000) but this problem has never occurred to me, yeah it doesnt magically give my laptop a switch and disable the igpu entirely, but for the most part my dgpu is used more often than my igpu

bayasdev commented 1 year ago

this is odd, i also use a muxless laptop (HP victus 16z-e000) but this problem has never occurred to me, yeah it doesnt magically give my laptop a switch and disable the igpu entirely, but for the most part my dgpu is used more often than my igpu

Can you try the latest changes from the rewrite-pci branch?

PD: I'm prepping for version 3.0 and need testers 😉

bayasdev commented 1 year ago

Should be fixed on version 3

Juhayer-Al-Wasif commented 1 year ago

Hey, 👋

I am trying the new version still it doesn't work on my laptop when switched to Nvidia only mode

bayasdev commented 1 year ago

@Juhayer-Al-Wasif when the problem occurs open a TTY and capture the X.org logs from /var/log/Xorg.0.log

bayasdev commented 1 year ago

@Juhayer-Al-Wasif do you have xrandr installed on your system?

Juhayer-Al-Wasif commented 1 year ago

yes

Juhayer-Al-Wasif commented 1 year ago

The Nvidia mode now works properly if I setup blacklist nouveau in grub bootloader. this was issue. But then suspend mode doesn't work😳 on manjaro gnome, neither in Endeavor os XFCE

bayasdev commented 1 year ago

@Juhayer-Al-Wasif have you enabled the nvidia-suspend services according to the README?

Juhayer-Al-Wasif commented 1 year ago

I might be missing it

bayasdev commented 1 year ago

@Juhayer-Al-Wasif

sudo systemctl enable nvidia-{suspend,resume,hibernate}
Juhayer-Al-Wasif commented 1 year ago
NVreg_PreserveVideoMemoryAllocations

With nvidia-suspend service, this kernel parameter fixed the issue in manjaro xwayland.

Thank you @bayasdev