Optimus Manager doesn't work

I am trying to switch my alienware m14x r2 to use the nvidia gpu but optimus manager doesn’t work.

[154] INFO: # Xorg pre-start hook
[154] INFO: Previous state was: {'type': 'pending_pre_xorg_start', 'requested_mode': 'nvidia', 'current_mode': None}
[155] INFO: Requested mode is: nvidia
[1698] INFO: Available modules: ['nouveau', 'bbswitch', 'nvidia', 'nvidia_drm', 'nvidia_modeset', 'nvidia_uvm']
[1698] INFO: Unloading modules ['nouveau'] (if loaded)
[1710] INFO: switching=none, nothing to do
[1820] INFO: Loading module nvidia
[2219] 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' 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
[2221] INFO: Removing /etc/X11/xorg.conf.d/10-optimus-manager.conf (if present)
[2222] INFO: Writing state {'type': 'pre_xorg_start_failed', 'switch_id': '20220416T225847', 'requested_mode': 'nvidia'}

What do I need to do?

did you folowed the install guide:
https://github.com/Askannz/optimus-manager
if you are using wayland optimus want work

I did follow the guide. I commented out the display things in the config file.

did you also install the optimus-manager-qt? did you reboot after you installed? if not, just uninstall it, reboot, install it again together with the optimus manager qt, reboot, and try again using the gui

So uninstall both regular optimus manager and qt then reinstall both?

if you didnt reboot after you installed them, then yes uninstall them, reboot, install again, reboot… if you are using kde, then you dont need to edit any conf, just installing them, reboot should sufice

I rebooted after installing them. It still shows the same error.

[87] INFO: # Xorg pre-start hook
[87] INFO: Previous state was: {'type': 'pending_pre_xorg_start', 'requested_mode': 'nvidia', 'current_mode': None}
[88] INFO: Requested mode is: nvidia
[1710] INFO: Available modules: ['nouveau', 'bbswitch', 'nvidia', 'nvidia_drm', 'nvidia_modeset', 'nvidia_uvm']
[1711] INFO: Unloading modules ['nouveau'] (if loaded)
[1722] INFO: switching=none, nothing to do
[1831] INFO: Loading module nvidia
[2236] 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' 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
[2238] INFO: Removing /etc/X11/xorg.conf.d/10-optimus-manager.conf (if present)
[2238] INFO: Writing state {'type': 'pre_xorg_start_failed', 'switch_id': '20220417T071311', 'requested_mode': 'nvidia'}

Optimus manager just refuses to work.

For some reason the nvidia kernel module cannot be loaded.

Please post the output of

mhwd -li
> Installed PCI configs:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
           video-linux            2018.05.04                true            PCI
video-hybrid-intel-nvidia-390xx-bumblebee            2021.12.18               false            PCI


Warning: No installed USB configs!

Can you also run inxi -Gazy and post its output as well?

This is too old, won’t work with optimus-manager. You need video-hybrid-intel-nvidia-470xx-prime. If the specification sheet does not lie, then the machine has an “NVIDIA GT 650M” GPU, which should be supported by the aforementioned driver.

Graphics:
  Device-1: Intel 3rd Gen Core processor Graphics vendor: Dell driver: i915
    v: kernel ports: active: LVDS-1 empty: DP-1, DP-2, HDMI-A-1, HDMI-A-2, VGA-1
    bus-ID: 00:02.0 chip-ID: 8086:0166 class-ID: 0300
  Device-2: NVIDIA GK107M [GeForce GT 650M] vendor: Dell driver: N/A
    alternate: nouveau, nvidia_drm, nvidia pcie: gen: 3 speed: 8 GT/s lanes: 16
    bus-ID: 01:00.0 chip-ID: 10de:0fd1 class-ID: 0300
  Device-3: Suyin Laptop_Integrated_Webcam_HD type: USB driver: uvcvideo
    bus-ID: 1-1.5:3 chip-ID: 064e:8128 class-ID: 0e02
  Display: x11 server: X.Org v: 1.21.1.3 compositor: kwin_x11 driver: X:
    loaded: modesetting alternate: fbdev,vesa gpu: i915 display-ID: :0
    screens: 1
  Screen-1: 0 s-res: 1600x900 s-dpi: 96 s-size: 423x238mm (16.7x9.4")
    s-diag: 485mm (19.1")
  Monitor-1: LVDS-1 model: LG built: 2011 res: 1600x900 hz: 60 dpi: 132
    gamma: 1.2 size: 309x174mm (12.2x6.9") diag: 355mm (14") ratio: 16:9
    modes: 1600x900
  OpenGL: renderer: Mesa DRI Intel HD Graphics 4000 (IVB GT2)
    v: 4.2 Mesa 21.3.7 compat-v: 3.0 direct render: Yes

I installed the video-hybrid-intel-nvidia-470xx-prime but it still has the same error.

> Installed PCI configs:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
           video-linux            2018.05.04                true            PCI
video-hybrid-intel-nvidia-470xx-prime            2021.12.18               false            PCI
     video-modesetting            2020.01.13                true            PCI


Warning: No installed USB configs!

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

[70] INFO: # Xorg pre-start hook
[70] INFO: Previous state was: {'type': 'pending_pre_xorg_start', 'requested_mode': 'nvidia', 'current_mode': None}
[71] INFO: Requested mode is: nvidia
[1992] INFO: Available modules: ['nouveau', 'nvidia', 'nvidia_drm', 'nvidia_modeset', 'nvidia_uvm']
[1992] INFO: Unloading modules ['nouveau'] (if loaded)
[2003] INFO: switching=none, nothing to do
[2101] INFO: Loading module nvidia
[2711] 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' 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
[2713] INFO: Removing /etc/X11/xorg.conf.d/10-optimus-manager.conf (if present)
[2713] INFO: Writing state {'type': 'pre_xorg_start_failed', 'switch_id': '20220417T091933', 'requested_mode': 'nvidia'}

You have the open source drivers at the same time as the propietary drivers,uninstall video-linux and restart and try again,you can uninstall it with

sudo mhwd -r video-linux

Isn’t it necessary for a hybrid setup?

No,only video-modesetting with the prime drivers are necessary,I think video-modesetting are Intel related drivers but not sure about that,in my case I only have those installed.

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


Warning: No installed USB configs!

I removed the linux video drivers but the result remains the same.

    ~  mhwd -li                                                                                       ✔ 
> Installed PCI configs:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
video-hybrid-intel-nvidia-470xx-prime            2021.12.18               false            PCI
     video-modesetting            2020.01.13                true            PCI


Warning: No installed USB configs!
    ~  optimus-manager --print-mode                                                                   ✔ 
ERROR: the latest GPU setup attempt failed at Xorg pre-start hook.
Log at /var/log/optimus-manager/switch/switch-20220417T152543.log
Cannot execute command because of previous errors.

Did you cleanly remove everything (including configs or whatnot) and try again, reinstalling the video hybrid driver, reboot, then reinstall the Optimus Manager, reboot, then try?

What is the output if you run this as root?