bayasdev / envycontrol

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

Black screen after booting on nvidia mode. #92

Open SK10 opened 1 year ago

SK10 commented 1 year ago

System Information:

Additional context sudo envycontrol --verbose -s nvidia output:

Switching to nvidia mode
Enable ForceCompositionPipeline: False
Enable Coolbits: False
INFO: Removed file /etc/modprobe.d/nvidia.conf
INFO: Found Nvidia GPU at 01:00.0
INFO: Found Intel iGPU
INFO: Created file /etc/X11/xorg.conf
# Automatically generated by EnvyControl

Section "ServerLayout"
    Identifier "layout"
    Screen 0 "nvidia"
    Inactive "intel"
EndSection

Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
    BusID "PCI:1:0:0"
EndSection

Section "Screen"
    Identifier "nvidia"
    Device "nvidia"
    Option "AllowEmptyInitialConfiguration"
EndSection

Section "Device"
    Identifier "intel"
    Driver "modesetting"
EndSection

Section "Screen"
    Identifier "intel"
    Device "intel"
EndSection

INFO: Created file /etc/modprobe.d/nvidia.conf
# Automatically generated by EnvyControl

options nvidia-drm modeset=1
options nvidia NVreg_PreserveVideoMemoryAllocations=1

INFO: Found sddm Display Manager
INFO: Creating Xsetup backup
INFO: Created file /usr/share/sddm/scripts/Xsetup.bak
#!/bin/sh
# Xsetup - run as root before the login dialog appears

INFO: Created file /usr/share/sddm/scripts/Xsetup
#!/bin/sh
# Automatically generated by EnvyControl

xrandr --setprovideroutputsource "modesetting" NVIDIA-0
xrandr --auto

INFO: Added execution privilege to file /usr/share/sddm/scripts/Xsetup
Rebuilding the initramfs...
Successfully rebuilt the initramfs!
Operation completed successfully
Please reboot your computer for changes to take effect!
bayasdev commented 1 year ago

@SK10 we have the same laptop, are you sure the Nvidia drivers are properly loaded?

sudo akmods
sudo dmesg | grep nvidia
SK10 commented 1 year ago

@bayasdev Yeah great laptop. I'm currently on hybrid mode, here's the commands output

sudo akmods 
Checking kmods exist for 6.2.6-201.fsync.fc37.x86_64       [  OK  ]
sudo dmesg | grep nvidia
[    0.000000] Command line: BOOT_IMAGE=(hd0,gpt5)/vmlinuz-6.2.6-201.fsync.fc37.x86_64 root=UUID=0a38845d-27df-4b2d-aadb-33ccbc0fffd4 ro rootflags=subvol=@ quiet splash rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1
[    0.057916] Kernel command line: BOOT_IMAGE=(hd0,gpt5)/vmlinuz-6.2.6-201.fsync.fc37.x86_64 root=UUID=0a38845d-27df-4b2d-aadb-33ccbc0fffd4 ro rootflags=subvol=@ quiet splash rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1
[    8.218061] nvidia: module license 'NVIDIA' taints kernel.
[    8.319107] nvidia-nvlink: Nvlink Core is being initialized, major device number 234
[    8.319869] nvidia 0000:01:00.0: enabling device (0406 -> 0407)
[    8.320026] nvidia 0000:01:00.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=none:owns=none
[    8.613836] nvidia-modeset: Loading NVIDIA Kernel Mode Setting Driver for UNIX platforms  525.85.05  Sat Jan 14 00:40:03 UTC 2023
[    8.622676] [drm] [nvidia-drm] [GPU ID 0x00000100] Loading driver
[    9.400323] [drm] Initialized nvidia-drm 0.0.0 20160202 for 0000:01:00.0 on minor 1
bayasdev commented 1 year ago

@SK10 I'm not sure about Fedora KDE but I tested on Fedora 38 (Gnome) and envycontrol works as expected (gdm uses Wayland and fall backs to CPU copy for external screen).

Maybe they're now defaulting SDDM to Wayland or something that's not entirely compatible with Nvidia.

bayasdev commented 1 year ago

@SK10 please try creating a .conf file inside /etc/sddm.conf.d/ with:

DisplayServer=x11

Reboot and now SDDM should default to X11

SK10 commented 1 year ago

@bayasdev Just tried that, unfortunately the issue persisted.

bayasdev commented 1 year ago

@SK10 when the problem occurs try to open a TTY and capture the X.org logs from /var/log/Xorg.0.log

bayasdev commented 1 year ago

@SK10 I'm reading that Fedora doesn't ship with xrandr so try to install it before switching to Nvidia mode:

sudo dnf -y install xrandr
SK10 commented 1 year ago

@bayasdev here's the log: https://privatebin.net/?b5862a480d7981e4#E4x3HiozD5VUwXZuc9L6QUCtfRHwNiCpD4xXi8abWTGA I do have xrandr installed

bayasdev commented 1 year ago

@SK10 I think I found the problem, Fedora uses /etc/sddm/Xsetup and not /usr/share/sddm/scripts/Xsetup.

Switch to Nvidia mode and run the following commands:

# backup
sudo mv /etc/sddm/Xsetup /etc/sddm/Xsetup.bak

# move Envycontrol generated script to the correct path
sudo cp /usr/share/sddm/scripts/Xsetup /etc/sddm/Xsetup

# also give it exec permissions
sudo chmod +x /etc/sddm/Xsetup

sudo reboot

Let me know if it works 😉

SK10 commented 1 year ago

Unfortunately it didn't work. Have I done something wrong?

 ls -l /etc/sddm
 total 20
-rw-r--r--. 1 root root  141 December  31 00:55 README.scripts
-rwxr-xr-x. 1 root root 1570 Octobor 25 09:06 wayland-session
-rwxr-xr-x  1 root root  122 March   19 19:01 Xsetup
-rwxr-xr-x. 1 root root   70 Octobor 25 09:06 Xsetup.bak
-rwxr-xr-x. 1 root root   53 Octobor 25 09:06 Xstop
 cat /etc/sddm/Xsetup 
#!/bin/sh
# Automatically generated by EnvyControl

xrandr --setprovideroutputsource "modesetting" NVIDIA-0
xrandr --auto
bayasdev commented 1 year ago

@SK10 let me see your sddm logs

journalctl -u sddm.service -b
SK10 commented 1 year ago

@bayasdev

March 20 06:51:48 nobara-pc systemd[1]: Started sddm.service - Simple Desktop Display Manager.
March 20 06:51:53 nobara-pc sddm-helper[1317]: pam_unix(sddm-greeter:session): session opened for user sddm(uid=985) by (uid=0)
March 20 06:51:53 nobara-pc sddm-helper[1317]: Starting X11 session: "" "/usr/bin/sddm-greeter --socket /tmp/sddm-:0-OPcFMp --theme /usr/share/sddm/themes/breeze"