Bumblebee-Project / Bumblebee

Bumblebee daemon and client rewritten in C
http://www.bumblebee-project.org/
GNU General Public License v3.0
1.29k stars 144 forks source link

Unloading module nvidia-drm in use on Ubutnu 20.10 #1075

Closed m1st0 closed 3 years ago

m1st0 commented 3 years ago

After loading modules, turning the discrete card on, and then running a program under optirun, I unload the kernel modules as understood to turn off my discrete card as follows:

sudo rmmod nvidia_drm
sudo rmmod nvidia_modeset
sudo rmmod nvidia_uvm
sudo rmmod nvidia
sudo tee /proc/acpi/bbswitch <<<OFF

However this fails to turn off my nvidia card. Syslog reports bbswitch: device 0000:01:00.0 is in use by driver 'nvidia', refusing OFF . Thereby I check down the modules that failed to unload one by one. Module nvidia won't unload due to nvidia-drm, so I try to manually unload it again:

sudo modprobe -r nvidia-drm
  modprobe: FATAL: Module nvidia_drm is in use.
sudo rmmod -f nvidia-drm
  rmmod: ERROR: ../libkmod/libkmod-module.c:799 kmod_module_remove_module() could not remove 'nvidia_drm': Resource temporarily unavailable
  rmmod: ERROR: could not remove module nvidia-drm: Resource temporarily unavailable

Checking on what is using nvidia-drm, sudo lsmod | grep nvidia results in

nvidia_drm             53248  2
nvidia_modeset       1228800  3 nvidia_drm
nvidia              34136064  83 nvidia_modeset
drm_kms_helper        225280  2 nvidia_drm,i915
drm                   565248  17 drm_kms_helper,nvidia_drm,i915

As a last resort, I can directly force the nvidia card off , but my system doesn't seem to be in a good state from:

sudo modprobe acpi_call
sudo tee /proc/acpi/call <<<'\_SB_.PCI0.PEG0.PEGP._OFF'

I am on nvidia version 460.56-0ubuntu0.20.10.1 . Please help on the drm issue.

m1st0 commented 3 years ago

After running ps aux | grep nvidia I found that the additional Xorg session on Display 8 was still running. Simple enough test then to turn it off by sudo fuser -k /tmp/.X11-unix/X8 before I unload the modules in question. This worked.

I then noticed bumblebee had the option turned on to keep the now unused Xorg session running.

Now my scripting works to load and unload all modules. In any case I hope my oversight helps in seeing some commands to work with the card and modules for other issues.