"Module nvidia is in use" but there are no processes running on the GPU

9,420

On Ubuntu 20.04, I've been able to fully unload and reload the NVIDIA modules with the following commands (performed via SSH or a text-only tty).

sudo service gdm3 stop

sudo rmmod nvidia_uvm
sudo rmmod nvidia_drm
sudo rmmod nvidia_modeset
sudo rmmod nvidia

# Then, reload them if desired:
sudo modprobe nvidia
sudo modprobe nvidia_modeset
sudo modprobe nvidia_drm
sudo modprobe nvidia_uvm

This came in handy e.g. when upgrading the NVIDIA driver without rebooting (which could happen unexpectedly via unattended apt upgrades).


As @Thomas pointed out in a comment, if there's still something preventing one of the modules from being unloaded, it's usually possible to figure out what with:

lsmod | grep nvidia
lsof | grep nvidia
Share:
9,420

Related videos on Youtube

Ivan Novikov
Author by

Ivan Novikov

Updated on September 18, 2022

Comments

  • Ivan Novikov
    Ivan Novikov over 1 year

    I am trying to configure VirtualGL, and the configuration gives the following message:

    IMPORTANT NOTE: Your system uses modprobe.d to set device permissions. You
    must execute rmmod nvidia with the display manager stopped in order for the
    new device permission settings to become effective.
    

    When I try running rmmod nvidia (or with sudo), it says that module nvidia is in use:

    rmmod: ERROR: Module nvidia is in use by: nvidia_uvm nvidia_modeset

    I have already stopped my window manager by running sudo systemctl stop sddm.service, so when I check nvidia-smi it says that there are no processes running on the GPU.

    Most of the threads I found on this issue are related to bumblebee, but I don't even have it insalled.

    Output of nvidia-smi:

    +-----------------------------------------------------------------------------+
    | NVIDIA-SMI 430.40       Driver Version: 430.40       CUDA Version: 10.1     |
    |-------------------------------+----------------------+----------------------+
    | GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
    | Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
    |===============================+======================+======================|
    |   0  GeForce GTX 1080    Off  | 00000000:01:00.0 Off |                  N/A |
    | 33%   39C    P8    12W / 200W |      9MiB /  8119MiB |      0%      Default |
    +-------------------------------+----------------------+----------------------+
    
    +-----------------------------------------------------------------------------+
    | Processes:                                                       GPU Memory |
    |  GPU       PID   Type   Process name                             Usage      |
    |=============================================================================|
    |  No running processes found                                                 |
    +-----------------------------------------------------------------------------+
    

    Ubuntu 18.04

    • Admin
      Admin over 4 years
      Try to run modprobe -r nvidia_uvm; modprobe -r nvidia_modeset or if it fails change the order of the two modules. If you then still cannot modprobe -r nvidia add the output of lsmod | grep nvidia and lsof | grep nvidia to your question.
  • Laurent Jospin
    Laurent Jospin over 2 years
    I have a problem when I try to run 'sudo rmmod nvidia_modeset'. This is block by a process called nvidia-pe (I suppose this is the persistence deamon). How can I disable the deamon ?