[Optimus-manager] Can't switch to nvidia card

I have installed Optimus-manager on my DELL XPS 15 7590. I am mostly interested in using the Intel GPU, but I have noticed that switching to Nvidia is never possible.

Some information.

My inxi -Fzy:

System:
  Kernel: 5.10.15-1-MANJARO x86_64 bits: 64 Desktop: GNOME 3.38.3 
  Distro: Manjaro Linux 
Machine:
  Type: Laptop System: Dell product: XPS 15 7590 v: N/A serial: <filter> 
  Mobo: Dell model: 018W12 v: A06 serial: <filter> UEFI: Dell v: 1.9.1 
  date: 12/14/2020 
Battery:
  ID-1: BAT0 charge: 72.0 Wh condition: 95.9/97.0 Wh (99%) 
CPU:
  Info: 6-Core model: Intel Core i7-9750H bits: 64 type: MT MCP 
  L2 cache: 12 MiB 
  Speed: 800 MHz min/max: 800/2600 MHz Core speeds (MHz): 1: 800 2: 800 3: 801 
  4: 800 5: 800 6: 800 7: 800 8: 800 9: 800 10: 800 11: 800 12: 800 
Graphics:
  Device-1: Intel UHD Graphics 630 driver: i915 v: kernel 
  Device-2: NVIDIA TU117M [GeForce GTX 1650 Mobile / Max-Q] driver: N/A 
  Device-3: Microdia Integrated_Webcam_HD type: USB driver: uvcvideo 
  Display: x11 server: X.org 1.20.10 driver: loaded: modesetting 
  unloaded: intel resolution: <missing: xdpyinfo> 
  OpenGL: renderer: Mesa Intel UHD Graphics 630 (CFL GT2) v: 4.6 Mesa 20.3.4 
Audio:
  Device-1: Intel Cannon Lake PCH cAVS driver: snd_hda_intel 
  Sound Server: ALSA v: k5.10.15-1-MANJARO 
Network:
  Device-1: Intel Wi-Fi 6 AX200 driver: iwlwifi 
  IF: wlp59s0 state: up mac: <filter> 
  IF-ID-1: virbr0 state: down mac: <filter> 
Bluetooth:
  Device-1: Intel AX200 Bluetooth type: USB driver: btusb 
  Message: Required tool hciconfig not installed. Check --recommends 
Drives:
  Local Storage: total: 476.94 GiB used: 156.15 GiB (32.7%) 
  ID-1: /dev/nvme0n1 vendor: Western Digital model: PC SN730 NVMe WDC 512GB 
  size: 476.94 GiB 
Partition:
  ID-1: / size: 349.36 GiB used: 156.15 GiB (44.7%) fs: ext4 dev: /dev/dm-0 
  ID-2: /boot/efi size: 511 MiB used: 500 KiB (0.1%) fs: vfat 
  dev: /dev/nvme0n1p7 
Swap:
  ID-1: swap-1 type: file size: 10 GiB used: 0 KiB (0.0%) file: /swapfile 
Sensors:
  System Temperatures: cpu: 43.0 C mobo: N/A 
  Fan Speeds (RPM): cpu: 2409 fan-2: 2421 
Info:
  Processes: 351 Uptime: 20m Memory: 15.28 GiB used: 4.6 GiB (30.1%) 
  Shell: Zsh inxi: 3.3.01 

First problem that happens all the time: the command optimus-manager --status fails:

ERROR: the latest GPU setup attempt failed at Xorg pre-start hook.
Log at /var/log/optimus-manager/switch/switch-20210223T084844.log

Cannot execute command because of previous errors.

To make it run, I have to run the command prime-offload first. Note: this works only once since I reboot. After I’ve used it once, and attempted to switch GPU, I will always get the error above. Anyway, if I manage to give the command optimus-manager --switch nvidia

feb 23 08:48:44 manjaro gdm[3843]: [11] INFO: # Xorg pre-start hook
feb 23 08:48:44 manjaro gdm[3843]: [11] INFO: Previous state was: {'type': 'pending_pre_xorg_start', 'requested_mode': 'nvidia', 'current_mode': 'intel'}
feb 23 08:48:44 manjaro gdm[3843]: [11] INFO: Requested mode is: nvidia
feb 23 08:48:44 manjaro gdm[3843]: [11] INFO: Checking for GDM display servers
feb 23 08:48:44 manjaro gdm[3843]: [340] INFO: Available modules: ['nouveau', 'bbswitch', 'nvidia', 'nvidia_drm', 'nvidia_modeset', 'nvidia_uvm']
feb 23 08:48:44 manjaro gdm[3843]: [340] INFO: Unloading modules ['nouveau'] (if loaded)
feb 23 08:48:44 manjaro gdm[3843]: [344] INFO: Loading module bbswitch
feb 23 08:48:44 manjaro gdm[3843]: [347] INFO: Setting GPU power to ON via bbswitch
feb 23 08:48:44 manjaro gdm[3843]: [462] INFO: Loading module nvidia
feb 23 08:48:44 manjaro gdm[3843]: [749] ERROR: Xorg pre-start setup error
feb 23 08:48:44 manjaro gdm[3843]: Traceback (most recent call last):
feb 23 08:48:44 manjaro gdm[3843]:   File "/usr/lib/python3.9/site-packages/optimus_manager/bash.py", line 11, in exec_bash
feb 23 08:48:44 manjaro gdm[3843]:     out = subprocess.check_output(
feb 23 08:48:44 manjaro gdm[3843]:   File "/usr/lib/python3.9/subprocess.py", line 420, in check_output
feb 23 08:48:44 manjaro gdm[3843]:     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
feb 23 08:48:44 manjaro gdm[3843]:   File "/usr/lib/python3.9/subprocess.py", line 524, in run
feb 23 08:48:44 manjaro gdm[3843]:     raise CalledProcessError(retcode, process.args,
feb 23 08:48:44 manjaro gdm[3843]: subprocess.CalledProcessError: Command '['bash', '-c', 'modprobe nvidia NVreg_UsePageAttributeTable=1']' returned non-zero exit status 1.
feb 23 08:48:44 manjaro gdm[3843]: During handling of the above exception, another exception occurred:
feb 23 08:48:44 manjaro gdm[3843]: Traceback (most recent call last):
feb 23 08:48:44 manjaro gdm[3843]:   File "/usr/lib/python3.9/site-packages/optimus_manager/kernel.py", line 179, in _load_module
feb 23 08:48:44 manjaro gdm[3843]:     exec_bash("modprobe %s %s" % (module, options))
feb 23 08:48:44 manjaro gdm[3843]:   File "/usr/lib/python3.9/site-packages/optimus_manager/bash.py", line 18, in exec_bash
feb 23 08:48:44 manjaro gdm[3843]:     raise BashError(
feb 23 08:48:44 manjaro gdm[3843]: optimus_manager.bash.BashError: Failed to execute 'modprobe nvidia NVreg_UsePageAttributeTable=1' :
feb 23 08:48:44 manjaro gdm[3843]: modprobe: ERROR: could not insert 'nvidia': No such device
feb 23 08:48:44 manjaro gdm[3843]: During handling of the above exception, another exception occurred:
feb 23 08:48:44 manjaro gdm[3843]: Traceback (most recent call last):
feb 23 08:48:44 manjaro gdm[3843]:   File "/usr/lib/python3.9/site-packages/optimus_manager/hooks/pre_xorg_start.py", line 45, in main
feb 23 08:48:44 manjaro gdm[3843]:     setup_kernel_state(config, prev_state, requested_mode)
feb 23 08:48:44 manjaro gdm[3843]:   File "/usr/lib/python3.9/site-packages/optimus_manager/kernel.py", line 21, in setup_kernel_state
feb 23 08:48:44 manjaro gdm[3843]:     _nvidia_up(config)
feb 23 08:48:44 manjaro gdm[3843]:   File "/usr/lib/python3.9/site-packages/optimus_manager/kernel.py", line 56, in _nvidia_up
feb 23 08:48:44 manjaro gdm[3843]:     _load_nvidia_modules(config, available_modules)
feb 23 08:48:44 manjaro gdm[3843]:   File "/usr/lib/python3.9/site-packages/optimus_manager/kernel.py", line 109, in _load_nvidia_modules
feb 23 08:48:44 manjaro gdm[3843]:     _load_module(available_modules, "nvidia", options="NVreg_UsePageAttributeTable=%d" % pat_value)
feb 23 08:48:44 manjaro gdm[3843]:   File "/usr/lib/python3.9/site-packages/optimus_manager/kernel.py", line 181, in _load_module
feb 23 08:48:44 manjaro gdm[3843]:     raise KernelSetupError("error running modprobe for %s : %s" % (module, str(e)))
feb 23 08:48:44 manjaro gdm[3843]: optimus_manager.kernel.KernelSetupError: error running modprobe for nvidia : Failed to execute 'modprobe nvidia NVreg_UsePageAttributeTable=1' :
feb 23 08:48:44 manjaro gdm[3843]: modprobe: ERROR: could not insert 'nvidia': No such device
feb 23 08:48:44 manjaro gdm[3843]: [750] INFO: Removing /etc/X11/xorg.conf.d/10-optimus-manager.conf (if present)
feb 23 08:48:44 manjaro gdm[3843]: [750] INFO: Writing state {'type': 'pre_xorg_start_failed', 'switch_id': '20210223T084844', 'requested_mode': 'nvidia'}

To make a long story short, loading the nvidia driver fails, and the new session is started loading again the intel driver.

My problem seems very similar to the one described in this old issue. I’ve tried some solutions described there but I didn’t try uninstalling optimus-manager and the video drivers because I didn’t want to risk being unable to boot.

That is all I have. Happy if someone can help.

  1. In the future, when providing code/output, please copy-paste that output in-between 3 backticks ``` at the beginning and end of the code/text so that the output looks like this:

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
    Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    

    instead of using HTML codes

    (as that makes both our lives much easier)

  2. Oh my! How much work you’ve put into this to get your post to display correctly! :open_mouth:

  3. is your issue: there is no driver loaded, so:

  4. How did you install the nVidia drivers?

:thinking:

P.S. If you’re unfamiliar with markdown, please see this as it might contain some things that will make your life easier…

Thanks for the formatting tips!
Regarding the issue, I ended up uninstalling Optimus Manager. I didn’t have big problems with the Intel drivers and I don’t need the Nvidia gpu for things like gaming. So I’ve installed nvidia-prime (which allows to launch specific apps with the instruction of using the nVidia driver) and I’m fine like this.
FYI, I had installed the Nvidia driver through Manjaro Settings Manager. To have the driver loaded at startup I needed to create a custom /etc/X11/xorg.conf file with the following text:

Section "ServerLayout"
  Identifier "layout"
  Screen 0 "iGPU"
  Option "AllowNVIDIAGPUScreens"
EndSection

Section "Device"
  Identifier "iGPU"
  Driver "intel"
  BusID "PCI:0:2:0"
EndSection

Section "Screen"
  Identifier "iGPU"
  Device "iGPU"
EndSection

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

Not at all! I just used Gnome terminal’s “copy as HTML” :wink:

1 Like

I’ve marked this answer as the solution to your question as it is by far the best answer you’ll get.

However, if you disagree with my choice, please feel free to take any other answer as the solution to your question or even remove the solution altogether: You are in control! (If you disagree with my choice, just send me a personal message and explain why I shouldn’t have done this or :heart: or :+1: if you agree)

:innocent:
P.S. In the future, please don’t forget to come back and click the 3 dots below the answer to mark a solution like this below the answer that helped you most:
Solution
so that the next person that has the exact same problem you just had will benefit from your post as well as your question will now be in the “solved” status.

Thank you. It’s not a proper solution to the initial problem but it’s still a way to get my laptop working fine, so it’s an acceptable solution.

If someone else can be helped by your research, leave it in. If you still need more help, take it out! (I’m just an editor here, not a mod, so I only suggest things)

:wink:

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.