You are not logged in.

#1 2020-09-24 10:38:13

alexghergh
Member
Registered: 2020-09-24
Posts: 2

Cannot unload Nvidia Driver after loading it through optimus-manager

Hello there,

I tried using optimus-manager and bbswitch to switch between the Nvidia card and the Intel card.

Switching to nvidia works as expected: optimus-manager loads the driver and its dependencies. But switching back doesn't work for whatever reason.

As far as I could debug, this is the output of

lsmod | grep nvidia

---

nvidia              27697152  3

And trying to do

modprobe -r nvidia

yields:

modprobe: FATAL: Module nvidia is in use.

I tried with both the nvidia package and nvidia-dkms, both of them have the same output.

Also if I reboot and manually load the nvidia module, I can unload it after that. But if the nvidia module is loaded through optimus-manager, it cannot be unloaded.

I also think it's important to mention that it used to work a few weeks ago. What I did to break it is I reinstalled the optimus-manager AUR package (but it hasn't been updated since then, so I cannot imagine why reinstalling it would do any harm).

Output of uname -r:

5.8.10-arch1-1

Might this be a kernel issue? Is there a point in switching to linux-lts?

Thank you

Edit: Tried with Linux-lts as well, the same thing happens, nvidia won't unload for whatever reason.

Last edited by alexghergh (2020-09-24 11:11:08)

Offline

#2 2020-09-24 15:31:29

GaKu999
Member
From: US/Eastern
Registered: 2020-06-21
Posts: 703

Re: Cannot unload Nvidia Driver after loading it through optimus-manager

Have you recompiled the AUR package?

Just in case, attempt a reinstall of nvidia and recompile & install optimus-manager.

After a cold boot, repeat the steps that reproduce the bug, aka, unable to switch from nvidia to intel, and post the commands with the output.


What's up doc?

Offline

#3 2020-09-24 19:07:29

alexghergh
Member
Registered: 2020-09-24
Posts: 2

Re: Cannot unload Nvidia Driver after loading it through optimus-manager

Thank you for the reply.

So doing what you said, here it is:

1) I reinstalled nvidia-dkms (since I'm using the rolling kernel), after first completely removing it through pacman -Rsn nvidia-dkms:

pacman -S nvidia-dkms

2) Reinstalled bbswitch-dkms, after completely removing it as above:

pacman -S bbswitch-dkms

3) I reinstalled optimus-manager (through AUR):

git clone https://aur.archlinux.org/optimus-manager.git
cd optimus-manager
makepkg -si

At this point, I rebooted once. So far so good. The nvidia module is not loaded (lsmod displays nothing related to it).

4) Switch from intel to nvidia:

optimus-manager --switch nvidia

This works as intended, the nvidia module is loaded and everything seems to work fine. Output of lsmod | grep nvidia:

nvidia_drm             57344  6
nvidia_modeset       1216512  4 nvidia_drm
nvidia              27697152  427 nvidia_modeset
drm_kms_helper        262144  2 nvidia_drm,i915
drm                   585728  9 drm_kms_helper,nvidia_drm,i915

5) Now, when trying to switch back to intel, the nvidia module stays loaded:

optimus-manager --switch intel

Output of lsmod | grep nvidia:

nvidia              27697152  3

6) Trying to switch back again to nvidia, this happens:

optimus-manager --switch nvidia

Output:

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

Cannot execute command because of previous errors.

And the log in the error has this output:

[9] INFO: # Xorg pre-start hook
[9] INFO: Previous state was: {'type': 'pending_pre_xorg_start', 'requested_mode': 'intel', 'current_mode': 'nvidia'}
[9] INFO: Requested mode is: intel
[9] INFO: Checking for GDM display servers
[895] INFO: Available modules: ['nouveau', 'bbswitch', 'nvidia', 'nvidia_drm', 'nvidia_modeset', 'nvidia_uvm']
[895] INFO: Unloading modules ['nvidia_drm', 'nvidia_modeset', 'nvidia_uvm', 'nvidia'] (if loaded)
[954] ERROR: Xorg pre-start setup error
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/optimus_manager/bash.py", line 11, in exec_bash
    out = subprocess.check_output(
  File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.8/subprocess.py", line 512, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['bash', '-c', 'modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/optimus_manager/kernel.py", line 196, in _unload_modules
    exec_bash("modprobe -r " + " ".join(modules_to_unload))
  File "/usr/lib/python3.8/site-packages/optimus_manager/bash.py", line 18, in exec_bash
    raise BashError(
optimus_manager.bash.BashError: Failed to execute 'modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia' :
modprobe: FATAL: Module nvidia is in use.


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/optimus_manager/hooks/pre_xorg_start.py", line 45, in main
    setup_kernel_state(config, prev_state, requested_mode)
  File "/usr/lib/python3.8/site-packages/optimus_manager/kernel.py", line 24, in setup_kernel_state
    _nvidia_down(config)
  File "/usr/lib/python3.8/site-packages/optimus_manager/kernel.py", line 65, in _nvidia_down
    _unload_nvidia_modules(available_modules)
  File "/usr/lib/python3.8/site-packages/optimus_manager/kernel.py", line 148, in _unload_nvidia_modules
    _unload_modules(available_modules, ["nvidia_drm", "nvidia_modeset", "nvidia_uvm", "nvidia"])
  File "/usr/lib/python3.8/site-packages/optimus_manager/kernel.py", line 198, in _unload_modules
    raise KernelSetupError("Cannot unload modules %s : %s" % (str(modules_to_unload), str(e)))
optimus_manager.kernel.KernelSetupError: Cannot unload modules ['nvidia_drm', 'nvidia_modeset', 'nvidia_uvm', 'nvidia'] : Failed to execute 'modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia' :
modprobe: FATAL: Module nvidia is in use.

[957] INFO: Removing /etc/X11/xorg.conf.d/10-optimus-manager.conf (if present)
[958] INFO: Writing state {'type': 'pre_xorg_start_failed', 'switch_id': '20200924T220014', 'requested_mode': 'intel'}

I am not sure what exactly keeps using the Nvidia module, this seems really weird to me.

Offline

Board footer

Powered by FluxBB