Optimus-manager failed at switching to hybrid

I’ve tried to switch to hybrid mode using optimus-manager and after relogging i’ve got following error about optimus-manager:

> optimus-manager
ERROR: the latest GPU setup attempt failed at Xorg pre-start hook.
Log at /var/log/optimus-manager/switch/switch-20221115T153215.log
Cannot execute command because of previous errors.

> cat /var/log/optimus-manager/switch/switch-20221115T153215.log                               
[6] INFO: # Xorg pre-start hook
[6] INFO: Previous state was: {'type': 'pending_pre_xorg_start', 'requested_mode': 'hybrid', 'current_mode': 'integrated'}
[6] INFO: Requested mode is: hybrid
[24] INFO: Available modules: ['nouveau', 'nvidia', 'nvidia_drm', 'nvidia_modeset', 'nvidia_uvm']
[24] INFO: Unloading modules ['nouveau'] (if loaded)
[26] INFO: switching=none, nothing to do
[1344] INFO: Setting Nvidia PCI power state to auto
[1354] INFO: Writing "auto" to /sys/bus/pci/devices/0000:01:00.0/power/control
[1354] INFO: Writing "auto" to /sys/bus/pci/devices/0000:01:00.1/power/control
[1373] INFO: Loading module nvidia
[3658] 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' returned non-zero exit status 1.

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
[3660] INFO: Removing /etc/X11/xorg.conf.d/10-optimus-manager.conf (if present)
[3660] INFO: Writing state {'type': 'pre_xorg_start_failed', 'switch_id': '20221115T153215', 'requested_mode': 'hybrid'}

Most likely that command return 1 because of a kernel upgrade plus no reboot after that.

I’ve updated kernel to 6.0.8-1-MANJARO and still have the same problem. After reboot it’s still integrated mode.

[6] INFO: # Xorg pre-start hook
[6] INFO: Previous state was: {'type': 'pending_pre_xorg_start', 'requested_mode': 'hybrid', 'current_mode': 'integrated'}
[6] INFO: Requested mode is: hybrid
[24] INFO: Available modules: ['nouveau', 'nvidia', 'nvidia_drm', 'nvidia_modeset', 'nvidia_uvm']
[24] INFO: Unloading modules ['nouveau'] (if loaded)
[27] INFO: switching=none, nothing to do
[1357] INFO: Setting Nvidia PCI power state to auto
[1368] INFO: Writing "auto" to /sys/bus/pci/devices/0000:01:00.0/power/control
[1368] INFO: Writing "auto" to /sys/bus/pci/devices/0000:01:00.1/power/control
[1371] INFO: Loading module nvidia
[3870] 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' returned non-zero exit status 1.

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
[3871] INFO: Removing /etc/X11/xorg.conf.d/10-optimus-manager.conf (if present)
[3871] INFO: Writing state {'type': 'pre_xorg_start_failed', 'switch_id': '20221116T211529', 'requested_mode': 'hybrid'}

Can you run this?

sudo modprobe --verbose --remove nvidia
sudo modprobe --verbose nvidia NVreg_UsePageAttributeTable=1 NVreg_DynamicPowerManagement=0x02

That issue only happens with linux 6.0 ?

Previously i’ve got 5.15

sudo modprobe --verbose nvidia NVreg_UsePageAttributeTable=1 NVreg_DynamicPowerManagement=0x02      
insmod /lib/modules/6.0.8-1-MANJARO/extramodules/nvidia.ko.xz "NVreg_DynamicPowerManagement=0x02" NVreg_UsePageAttributeTable=1 NVreg_DynamicPowerManagement=0x02
modprobe: ERROR: could not insert 'nvidia': No such device

Here is also result of inxi -Gazy, because i saw that nvidia wasn’t founded.

inxi -Gazy                                                                                             1 ✘ 
Graphics:
  Device-1: Intel CometLake-H GT2 [UHD Graphics] vendor: Micro-Star MSI
    driver: i915 v: kernel arch: Gen-9.5 process: Intel 14nm built: 2016-20
    ports: active: eDP-1 empty: none bus-ID: 00:02.0 chip-ID: 8086:9bc4
    class-ID: 0300
  Device-2: NVIDIA GA106M [GeForce RTX 3060 Mobile / Max-Q]
    vendor: Micro-Star MSI driver: N/A alternate: nouveau, nvidia_drm, nvidia
    non-free: 520.xx+ status: current (as of 2022-10) arch: Ampere code: GAxxx
    process: TSMC n7 (7nm) built: 2020-22 pcie: gen: 3 speed: 8 GT/s lanes: 16
    link-max: gen: 4 speed: 16 GT/s bus-ID: 01:00.0 chip-ID: 10de:2520
    class-ID: 0300
  Display: x11 server: X.Org v: 21.1.4 compositor: kwin_x11 driver: X:
    loaded: modesetting dri: iris gpu: i915 display-ID: :0 screens: 1
  Screen-1: 0 s-res: 1920x1080 s-dpi: 96 s-size: 508x285mm (20.00x11.22")
    s-diag: 582mm (22.93")
  Monitor-1: eDP-1 model: ChiMei InnoLux 0x1521 built: 2020 res: 1920x1080
    hz: 144 dpi: 142 gamma: 1.2 size: 344x193mm (13.54x7.6") diag: 394mm (15.5")
    ratio: 16:9 modes: 1920x1080
  API: OpenGL v: 4.6 Mesa 22.2.3 renderer: Mesa Intel UHD Graphics (CML GT2)
    direct render: Yes

you dont have any nvidia drivers, they are N/A …
post output from:
mhwd -l -li

> Installed PCI configs:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
     video-modesetting            2020.01.13                true            PCI
video-hybrid-intel-nvidia-prime            2021.11.04               false            PCI


Warning: No installed USB configs!
> 0000:03:00.0 (0200:10ec:8168) Network controller Realtek Semiconductor Co., Ltd.:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
         network-r8168            2016.04.20                true            PCI


> 0000:01:00.0 (0300:10de:2520) Display controller nVidia Corporation:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
video-hybrid-intel-nvidia-prime            2021.11.04               false            PCI
video-hybrid-intel-nvidia-470xx-prime            2021.11.04               false            PCI
          video-nvidia            2021.11.04               false            PCI
    video-nvidia-470xx            2021.11.04               false            PCI
           video-linux            2018.05.04                true            PCI
     video-modesetting            2020.01.13                true            PCI
            video-vesa            2017.03.12                true            PCI


> 0000:00:02.0 (0300:8086:9bc4) Display controller Intel Corporation:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
video-hybrid-intel-nvidia-prime            2021.11.04               false            PCI
video-hybrid-intel-nvidia-470xx-prime            2021.11.04               false            PCI
           video-linux            2018.05.04                true            PCI
     video-modesetting            2020.01.13                true            PCI
            video-vesa            2017.03.12                true            PCI

does it happens also with the 5.15 kernel?
if yes add this parameter:
kate /etc/default/grub
and in this line: GRUB_CMDLINE_LINUX_DEFAULT inside the quotes add this parameter:
ibt=off
dont remove anything from there!, just add it to existing parameters, save the file, update grub:
sudo update-grub
reboot and try


if it doesnt work, post output from:
pacman -Qs 'optimus|bbswitch|bumblebee'
ls /etc/modprobe.d
find /etc/X11/ -name "*.conf"

Same problem. Outputs:

> pacman -Qs 'optimus|bbswitch|bumblebee'                                                      
local/optimus-manager 1.4+r12-2
    Management utility to handle GPU switching for Optimus laptops (Git version)
local/optimus-manager-qt 1.6.9-1
    A Qt interface for Optimus Manager that allows to configure and switch GPUs on Optimus laptops using the tray
    menu

> ls /etc/modprobe.d                                                                              
mhwd-gpu.conf

> find /etc/X11/ -name "*.conf"                                                                   
/etc/X11/mhwd.d/nvidia.conf
/etc/X11/xorg.conf.d/00-keyboard.conf
/etc/X11/xorg.conf.d/30-touchpad.conf

did you added the parameter?
if yes, uninstall optimus:
pamac remove optimus-manager optimus-manager-qt
reboot and check if the nvidia is detected:
inxi -G

I added this parameter. This is terminal output when i tried to uninstall optimus. Does it can be problem that i don’t have optimus-manager-qt?

> pamac remove optimus-manager optimus-manger-qt                                          
Error: target not found: optimus-manger-qt
> pamac remove optimus-manager                                                         
Preparing...
Checking dependencies...
Error: Failed to prepare transaction:
could not satisfy dependencies:
- removing optimus-manager breaks dependency 'optimus-manager>=1.4' required by optimus-manager-qt

you have there a typo:

Right. Here is inxi -G

> inxi -G                                                                       
Graphics:
  Device-1: Intel CometLake-H GT2 [UHD Graphics] driver: i915 v: kernel
  Device-2: NVIDIA GA106M [GeForce RTX 3060 Mobile / Max-Q] driver: N/A
  Display: x11 server: X.Org v: 21.1.4 driver: X: loaded: modesetting
    dri: iris gpu: i915 resolution: 1920x1080~144Hz
  API: OpenGL v: 4.6 Mesa 22.2.3 renderer: Mesa Intel UHD Graphics (CML GT2)

as you can see the driver is not being loaded…


post output from:
journalctl -b0 -g nvidia

> journalctl -b0 -g nvidia
lis 16 23:51:53 kacper-gf65thin10ue systemd-modules-load[295]: Module 'nvidia' is deny-listed
lis 16 23:51:53 kacper-gf65thin10ue systemd-modules-load[295]: Module 'nvidia_drm' is deny-listed
lis 16 23:51:53 kacper-gf65thin10ue systemd-modules-load[295]: Module 'nvidia_uvm' is deny-listed
lis 16 23:51:54 kacper-gf65thin10ue python3[462]: [28] INFO: Available modules: ['nouveau', 'nvidia', 'nvidia_drm', 'nvidia_modeset', 'nvidia_uvm']
lis 16 23:51:54 kacper-gf65thin10ue python3[462]: [28] INFO: Unloading modules ['nvidia_drm', 'nvidia_modeset', 'nvidia_uvm', 'nvidia'] (if loaded)
lis 16 23:51:54 kacper-gf65thin10ue python3[462]: [30] INFO: Setting Nvidia PCI power state to auto
lis 16 23:51:54 kacper-gf65thin10ue kernel: input: HDA NVidia HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input16
lis 16 23:51:54 kacper-gf65thin10ue kernel: input: HDA NVidia HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input17
lis 16 23:51:54 kacper-gf65thin10ue kernel: input: HDA NVidia HDMI/DP,pcm=8 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input18
lis 16 23:51:54 kacper-gf65thin10ue kernel: input: HDA NVidia HDMI/DP,pcm=9 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input19
lis 16 23:51:55 kacper-gf65thin10ue kernel: nvidia: loading out-of-tree module taints kernel.
lis 16 23:51:55 kacper-gf65thin10ue kernel: nvidia: module license 'NVIDIA' taints kernel.
lis 16 23:51:55 kacper-gf65thin10ue kernel: nvidia: module verification failed: signature and/or required key missing - tainting kernel
lis 16 23:51:56 kacper-gf65thin10ue kernel: nvidia-nvlink: Nvlink Core is being initialized, major device number 510
lis 16 23:51:57 kacper-gf65thin10ue kernel: nvidia 0000:01:00.0: enabling device (0000 -> 0003)
lis 16 23:51:57 kacper-gf65thin10ue kernel: NVRM: This PCI I/O region assigned to your NVIDIA device is invalid:
                                            NVRM: BAR0 is 0M @ 0x0 (PCI:0000:01:00.0)
lis 16 23:51:57 kacper-gf65thin10ue kernel: nvidia: probe of 0000:01:00.0 failed with error -1
lis 16 23:51:57 kacper-gf65thin10ue kernel: NVRM: The NVIDIA probe routine failed for 1 device(s).
lis 16 23:51:57 kacper-gf65thin10ue kernel: NVRM: None of the NVIDIA devices were initialized.
lis 16 23:51:57 kacper-gf65thin10ue kernel: nvidia-nvlink: Unregistered Nvlink Core, major device number 510
lis 16 23:51:57 kacper-gf65thin10ue systemd-udevd[335]: nvidia: Process '/usr/bin/bash -c '/usr/bin/mknod -Z -m 666 /dev/nvidiactl c $(grep nvidia-frontend /proc/devices | cut -d \  -f 1) 255'' failed with exit code 1.
lis 16 23:51:57 kacper-gf65thin10ue systemd-udevd[335]: nvidia: Process '/usr/bin/bash -c '/usr/bin/mknod -Z -m 666 /dev/nvidiactl c $(grep nvidia-frontend /proc/devices | cut -d \  -f 1) 255'' failed with exit code 1.

it looks like its being still blacklisted:

post output from:
pacman -Qs 'envycontrol|prim|acpi'

> pacman -Qs 'envycontrol|prim|ahci'                                           
local/libplacebo 4.208.0-1
    Reusable library for GPU-accelerated video/image rendering primitives
local/nvidia-prime 1.0-4
    NVIDIA Prime Render Offload configuration and utilities
local/python-cryptography 38.0.3-1
    A package designed to expose cryptographic recipes and primitives to Python developers
local/xorg-xrandr 1.5.1-2 (xorg-apps xorg)
    Primitive command line interface to RandR extension

i made a mistake there, should be acpi not ahci:
pacman -Qs acpi

> pacman -Qs 'envycontrol|prim|acpi'                                             
local/acpi 1.7-3
    Client for battery, power, and thermal readings
local/acpid 2.0.34-1
    A daemon for delivering ACPI power management events with netlink support
local/libplacebo 4.208.0-1
    Reusable library for GPU-accelerated video/image rendering primitives
local/nvidia-prime 1.0-4
    NVIDIA Prime Render Offload configuration and utilities
local/python-cryptography 38.0.3-1
    A package designed to expose cryptographic recipes and primitives to Python developers
local/xorg-xrandr 1.5.1-2 (xorg-apps xorg)
    Primitive command line interface to RandR extension

looks ok…
did you installed other programs for switching between gpus?

post also output from:
pacman -Qm