Repository: Askannz/optimus-manager

Issue #508: GPU Switch is pending after logout
Created: 2022-07-30T18:24:54Z
Hello.
When I do optimus-manager --switch nvidia everything seems to work fine, it logs out automaticly but when I log in back and do optimus-manager --status it says this:
`A GPU switch from integrated to nvidia is pending.
Log out and log back in to apply.
Optimus Manager (Client) version 1.4
Current GPU mode : integrated
GPU mode requested for next login : nvidia
GPU at startup : integrated
Temporary config path: no
`
System info:

Distro: Arch 5.15.55-2-lts
Desktop manager: KDE
Display manager: SDDM
Laptop: Asus TUF
optimus-manager version: latest stable

Logs:
/var/log/optimus-manager/switch/switch-20220731T001544.log:
[5] INFO: # Xorg pre-start hook [5] INFO: Previous state was: {'type': 'pending_pre_xorg_start', 'requested_mode': 'nvidia', 'current_mode': 'integrated'} [5] INFO: Requested mode is: nvidia [655] INFO: Available modules: ['nouveau', 'nvidia', 'nvidia_drm', 'nvidia_modeset', 'nvidia_uvm'] [655] INFO: Unloading modules ['nouveau'] (if loaded) [658] INFO: switching=none, nothing to do 
Thanks!

Duplicate issue #499: Unable to switch to nvidia video card
Created: 2022-06-05T17:51:29Z
Describe the bug
For some reason I'm unable to switch to the dedicated video card. After executing optimus-manager --switch nvidia and re-logging in, when I run optimus-manager --status I get this message:
ERROR: the latest GPU setup attempt failed at Xorg pre-start hook.
Log at /var/log/optimus-manager/switch/switch-20220605T194232.log
Cannot execute command because of previous errors.

This is the log mentioned in the error:
[5] INFO: # Xorg pre-start hook
[5] INFO: Previous state was: {'type': 'pending_pre_xorg_start', 'requested_mode': 'nvidia', 'current_mode': 'integrated'}
[5] INFO: Requested mode is: nvidia
[84] INFO: Available modules: ['nouveau', 'nvidia', 'nvidia_drm', 'nvidia_modeset', 'nvidia_uvm']
[84] INFO: Unloading modules ['nouveau'] (if loaded)
[85] INFO: switching=none, nothing to do
[99] INFO: Resetting Nvidia PCI device
[99] INFO: Starting hot reset sequence
[124] INFO: Removing Nvidia from PCI bridge
[145] INFO: Writing "1" to /sys/bus/pci/devices/0000:01:00.0/remove
[147] INFO: Triggering PCI hot reset of bridge 00:01.0
[155] INFO: Rescanning PCI bus
[174] INFO: Setting Nvidia PCI power state to on
[193] INFO: Writing "on" to /sys/bus/pci/devices/0000:01:00.0/power/control
[211] INFO: Loading module nvidia
[368] ERROR: Xorg pre-start setup error
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/optimus_manager/kernel.py", line 245, in _load_module
    subprocess.check_call(
  File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'modprobe nvidia NVreg_UsePageAttributeTable=1 NVreg_DynamicPowerManagement=0x02' died with <Signals.SIGSEGV: 11>.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/optimus_manager/hooks/pre_xorg_start.py", line 51, in main
    setup_kernel_state(config, prev_state, requested_mode)
  File "/usr/lib/python3.10/site-packages/optimus_manager/kernel.py", line 22, in setup_kernel_state
    _nvidia_up(config, hybrid=(requested_mode == "hybrid"))
  File "/usr/lib/python3.10/site-packages/optimus_manager/kernel.py", line 95, in _nvidia_up
    _load_nvidia_modules(config, available_modules)
  File "/usr/lib/python3.10/site-packages/optimus_manager/kernel.py", line 164, in _load_nvidia_modules
    _load_module(available_modules, "nvidia", options=nvidia_options)
  File "/usr/lib/python3.10/site-packages/optimus_manager/kernel.py", line 249, in _load_module
    raise KernelSetupError(f"Error running modprobe for {module}: {e.stderr}") from e
optimus_manager.kernel.KernelSetupError: Error running modprobe for nvidia: None
[369] INFO: Removing /etc/X11/xorg.conf.d/10-optimus-manager.conf (if present)
[369] INFO: Writing state {'type': 'pre_xorg_start_failed', 'switch_id': '20220605T194232', 'requested_mode': 'nvidia'}

System info

Your distribution: Arch linux
Your desktop manager: KDE
You display manager: SDDM
Your laptop model: Dell xps 15 (9510)
The version of optimus-manager you are using : latest stable release (optimus-manager)
Your custom optimus-manager configuration file

[amd]
DRI=3
driver=modesetting
tearfree=

[intel]
DRI=3
accel=
driver=intel
modeset=yes
tearfree=

[nvidia]
DPI=96
PAT=yes
allow_external_gpus=no
dynamic_power_management=fine
ignore_abi=no
modeset=yes
options=overclocking

[optimus]
auto_logout=yes
pci_power_control=yes
pci_remove=no
pci_reset=hot_reset
startup_auto_battery_mode=integrated
startup_auto_extpower_mode=nvidia
startup_mode=integrated
switching=none

Closing comment (2022-08-06T06:13:55Z): Seems related to #508, with the common factor being SDDM. After switching to LightDM my issue appeared to be resolved so this is likely an issue with SDDM.