Optimus-manager doesn't switch to nvidia

After running optimus-manager --switch nvidia and it logging me out as supposed, after the new log in, if I check the status optimus-manager --status I get:

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

I also tried editing the optimus conf file /etc/optimus-manager/optimus-manager.conf to make nvidia de default boot, as showed on their instructions github - optimus-manager under: “Configuration # Main configuration file”, but I get the same error when I check the status after boot.

This is the content of the error log:

[11] INFO: # Xorg pre-start hook
[11] INFO: Previous state was: {'type': 'pending_pre_xorg_start', 'requested_mode': 'nvidia', 'current_mode': 'integrated'}
[11] INFO: Requested mode is: nvidia
[468] INFO: Available modules: ['nouveau', 'nvidia', 'nvidia_drm', 'nvidia_modeset', 'nvidia_uvm']
[468] INFO: Unloading modules ['nouveau'] (if loaded)
[471] INFO: switching=none, nothing to do
[482] INFO: Nvidia card not visible in PCI bus, rescanning
[483] INFO: Rescanning PCI bus
[495] ERROR: Nvidia card not showing up in PCI bus after rescan. Continuing anyways.
[511] INFO: Loading module nvidia
[810] 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
[811] INFO: Removing /etc/X11/xorg.conf.d/10-optimus-manager.conf (if present)
[811] INFO: Writing state {'type': 'pre_xorg_start_failed', 'switch_id': '20220502T204038', 'requested_mode': 'nvidia'}

I tried with both kernel 5.15.32 LTS and 5.16.18, with same results.

In their general notes github - optimus-manager over “IMPORTANT : Manjaro KDE users” (I am running KDE) they state that one should edit the /etc/sddm.conf and comment two lines: DisplayCommand and DisplayStopCommand, which I did back in the day.

I checked that file, in case it was modified in recent KDE updates, and now I don’t see any line that starts with those parameters. If the idea was to comment them out, it shouldn’t be a problem if they are not present anymore, but I notice the difference.

Any ideas where I should start?

(Asus ROG flow x13)

in the error it says that nvidia card not detected… post output from:
mhwd -li

The output is:

> Installed PCI configs:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
           video-linux            2018.05.04                true            PCI
video-hybrid-amd-nvidia-prime            2021.12.18               false            PCI


Warning: No installed USB configs!

Maybe I should add that I blacklisted Nouveau drivers with:

echo "blacklist nouveau" >  /etc/modprobe.d/asus-flow-x13-nouveau.conf
echo "alias nouveau off" >> /etc/modprobe.d/asus-flow-x13-nouveau.conf

as showed here github - asus-flow-x13-linux, because they frozen the laptop at boot. But that was almost a year ago, when I got the laptop. It wasn’t a recent change, and I have been using optimus-manager since back then. But in case it is relevant to that “false” under, what I think is the “FREEDRIVER” column

looks like video modesseting is missing, post output from:
mhwd -l

That output is (I think it only shows info from the AMD integrated):

> 0000:04:00.0 (0300:1002:1638) Display controller ATI Technologies Inc:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
           video-linux            2018.05.04                true            PCI
     video-modesetting            2020.01.13                true            PCI
            video-vesa            2017.03.12                true            PCI

your nvidia card is not being detected… post output from:
inxi -Fazy

Thanks for your attention, man!

System:
  Kernel: 5.15.32-1-MANJARO arch: x86_64 bits: 64 compiler: gcc v: 11.2.0
    parameters: BOOT_IMAGE=/boot/vmlinuz-5.15-x86_64
    root=UUID=0eb5b762-52aa-428b-829d-e29fae0cdae4 rw quiet
    cryptdevice=UUID=a8804b83-f3d4-47c1-ab1a-a7882ae0bb65:luks-a8804b83-f3d4-47c1-ab1a-a7882ae0bb65
    root=/dev/mapper/luks-a8804b83-f3d4-47c1-ab1a-a7882ae0bb65
    udev.log_priority=3 acpi_backlight=vendor
  Desktop: KDE Plasma v: 5.24.4 tk: Qt v: 5.15.3 wm: kwin_x11 vt: 1 dm: SDDM
    Distro: Manjaro Linux base: Arch Linux
Machine:
  Type: Laptop System: ASUSTeK product: ROG Flow X13 GV301QH_GV301QH v: 1.0
    serial: <superuser required>
  Mobo: ASUSTeK model: GV301QH v: 1.0 serial: <superuser required>
    UEFI: American Megatrends LLC. v: GV301QH.407 date: 05/31/2021
Battery:
  ID-1: BAT0 charge: 36.0 Wh (62.0%) condition: 58.1/62.0 Wh (93.7%)
    volts: 15.9 min: 15.9 model: ASUSTeK ASUS Battery type: Li-ion serial: N/A
    status: not charging
  Device-1: hid-0018:04F3:2C82.0008-battery model: ELAN9008:00 04F3:2C82
    serial: N/A charge: N/A status: N/A
CPU:
  Info: model: AMD Ryzen 7 5800HS with Radeon Graphics bits: 64 type: MT MCP
    arch: Zen 3 family: 0x19 (25) model-id: 0x50 (80) stepping: 0
    microcode: 0xA50000C
  Topology: cpus: 1x cores: 8 tpc: 2 threads: 16 smt: enabled cache:
    L1: 512 KiB desc: d-8x32 KiB; i-8x32 KiB L2: 4 MiB desc: 8x512 KiB
    L3: 16 MiB desc: 1x16 MiB
  Speed (MHz): avg: 1815 high: 3180 min/max: 1200/3200 boost: disabled
    scaling: driver: acpi-cpufreq governor: performance cores: 1: 2932 2: 1397
    3: 1397 4: 1802 5: 3180 6: 1397 7: 1397 8: 1397 9: 1397 10: 1396 11: 1396
    12: 1396 13: 3038 14: 1396 15: 2736 16: 1397 bogomips: 102243
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm
  Vulnerabilities:
  Type: itlb_multihit status: Not affected
  Type: l1tf status: Not affected
  Type: mds status: Not affected
  Type: meltdown status: Not affected
  Type: spec_store_bypass
    mitigation: Speculative Store Bypass disabled via prctl and seccomp
  Type: spectre_v1
    mitigation: usercopy/swapgs barriers and __user pointer sanitization
  Type: spectre_v2 mitigation: Retpolines, IBPB: conditional, IBRS_FW,
    STIBP: always-on, RSB filling
  Type: srbds status: Not affected
  Type: tsx_async_abort status: Not affected
Graphics:
  Device-1: AMD Cezanne vendor: ASUSTeK driver: amdgpu v: kernel pcie: gen: 3
    speed: 8 GT/s lanes: 16 link-max: gen: 4 speed: 16 GT/s ports: active: eDP-1
    empty: DP-1,DP-2,HDMI-A-1 bus-ID: 04:00.0 chip-ID: 1002:1638
    class-ID: 0300
  Device-2: IMC Networks USB2.0 HD UVC WebCam type: USB driver: uvcvideo
    bus-ID: 3-4:3 chip-ID: 13d3:56dd class-ID: 0e02 serial: <filter>
  Display: x11 server: X.Org v: 1.21.1.3 compositor: kwin_x11 driver: X:
    loaded: amdgpu unloaded: modesetting alternate: fbdev,vesa gpu: amdgpu
    display-ID: :0 screens: 1
  Screen-1: 0 s-res: 1920x1200 s-dpi: 96 s-size: 508x317mm (20.00x12.48")
    s-diag: 599mm (23.57")
  Monitor-1: eDP-1 mapped: eDP model: Sharp LQ134N1JW52 built: 2020
    res: 1920x1200 hz: 120 dpi: 169 gamma: 1.2 size: 288x180mm (11.34x7.09")
    diag: 340mm (13.4") ratio: 16:10 modes: max: 1920x1200 min: 640x480
  OpenGL: renderer: AMD RENOIR (DRM 3.42.0 5.15.32-1-MANJARO LLVM 13.0.1)
    v: 4.6 Mesa 21.3.8 direct render: Yes
Audio:
  Device-1: AMD Renoir Radeon High Definition Audio driver: snd_hda_intel
    v: kernel pcie: gen: 3 speed: 8 GT/s lanes: 16 link-max: gen: 4
    speed: 16 GT/s bus-ID: 04:00.1 chip-ID: 1002:1637 class-ID: 0403
  Device-2: AMD ACP/ACP3X/ACP6x Audio Coprocessor vendor: ASUSTeK
    driver: N/A alternate: snd_pci_acp3x, snd_rn_pci_acp3x, snd_pci_acp5x pcie:
    gen: 3 speed: 8 GT/s lanes: 16 link-max: gen: 4 speed: 16 GT/s
    bus-ID: 04:00.5 chip-ID: 1022:15e2 class-ID: 0480
  Device-3: AMD Family 17h/19h HD Audio vendor: ASUSTeK
    driver: snd_hda_intel v: kernel pcie: gen: 3 speed: 8 GT/s lanes: 16
    link-max: gen: 4 speed: 16 GT/s bus-ID: 04:00.6 chip-ID: 1022:15e3
    class-ID: 0403
  Sound Server-1: ALSA v: k5.15.32-1-MANJARO running: yes
  Sound Server-2: JACK v: 1.9.20 running: no
  Sound Server-3: PulseAudio v: 15.0 running: yes
  Sound Server-4: PipeWire v: 0.3.49 running: yes
Network:
  Device-1: Intel Wi-Fi 6 AX200 driver: iwlwifi v: kernel pcie: gen: 2
    speed: 5 GT/s lanes: 1 bus-ID: 02:00.0 chip-ID: 8086:2723 class-ID: 0280
  IF: wlp2s0 state: up mac: <filter>
  IF-ID-1: virbr0 state: down mac: <filter>
  IF-ID-2: wg-mullvad state: unknown speed: N/A duplex: N/A mac: N/A
Bluetooth:
  Device-1: Intel AX200 Bluetooth type: USB driver: btusb v: 0.8 bus-ID: 1-4:4
    chip-ID: 8087:0029 class-ID: e001
  Report: rfkill ID: hci0 rfk-id: 1 state: down bt-service: enabled,running
    rfk-block: hardware: no software: yes address: see --recommends
Drives:
  Local Storage: total: 476.94 GiB used: 122.36 GiB (25.7%)
  SMART Message: Unable to run smartctl. Root privileges required.
  ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Western Digital
    model: PC SN530 SDBPTPZ-512G-1002 size: 476.94 GiB block-size:
    physical: 512 B logical: 512 B speed: 31.6 Gb/s lanes: 4 type: SSD
    serial: <filter> rev: 21106000 temp: 33.9 C scheme: GPT
Partition:
  ID-1: / raw-size: 338.87 GiB size: 332.48 GiB (98.12%)
    used: 122.32 GiB (36.8%) fs: ext4 dev: /dev/dm-0 maj-min: 254:0
    mapped: luks-a8804b83-f3d4-47c1-ab1a-a7882ae0bb65
  ID-2: /boot/efi raw-size: 260 MiB size: 256 MiB (98.46%)
    used: 42.1 MiB (16.4%) fs: vfat dev: /dev/nvme0n1p1 maj-min: 259:1
Swap:
  Alert: No swap data was found.
Sensors:
  System Temperatures: cpu: 57.0 C mobo: N/A gpu: amdgpu temp: 53.0 C
  Fan Speeds (RPM): cpu: 3100
Info:
  Processes: 403 Uptime: 27m wakeups: 4 Memory: 15.1 GiB
  used: 3.28 GiB (21.7%) Init: systemd v: 250 tool: systemctl Compilers:
  gcc: 11.2.0 clang: 13.0.1 Packages: 1461 pacman: 1425 lib: 381 flatpak: 36
  Shell: Zsh v: 5.8.1 default: Bash v: 5.1.16 running-in: kitty inxi: 3.3.15

if you check under the Graphics section, there is no nvidia…

That is true. Now I think I had to reboot to windows this morning, to remotely connect to my work computer (they only offer the VPN client (which is payed) for windows systems). This was the first time I did that (I am sick at home). And I believe the options of the Asus ROG app to how the cards should be handled can affect how linux detects them.

Let me reboot to windows and check!

Thanks for the attention!

Freaking hell, man. It was that. I only booted to windows like… 3 times since I got the laptop, so I don’t pay attention to that. Now I see there is a new mode to handle the nvidia-amd combo. The new mode changes to nvidia for “demanding apps” (like before) BUT!!! now, if you are on battery, it only stays in integrated amd graphics and disconnects the dedicated card. And… this morning, because I’m sick, I used it from bed :rofl: without plugging it.

I don’t know when that new mode was added. Anyway, the only 2 or 3 times I booted into windows it was connected to power, to play a non supported linux game, so I never noticed that.

:expressionless: sorry to bother with that “stupidity”. I slept so many hours today that I completely forgot about this morning :rofl::rofl:.

Thanks again!

its ok, things happen haha … at least, its not broken…

1 Like