# Unable to rmmod nvidia

## reikdas

I am unable to do rmmod nvidia. 

This is my nvidia-rmmod conf - (I set it up with uvm and kms after first getting bumblebee to work as shown in the wiki)

```
reik@reik-msi /etc/modprobe.d $ cat nvidia-rmmod.conf

# Nvidia UVM support

remove nvidia modprobe -r --ignore-remove nvidia_drm nvidia_modeset nvidia_uvm nvidia
```

These are the errors I faced while trying to rmmod nvidia -

```
reik-msi /home/reik # rmmod nvidia

rmmod: ERROR: Module nvidia is in use

reik-msi /home/reik # rmmod nvidia_drm

rmmod: ERROR: Module nvidia_drm is not currently loaded

reik-msi /home/reik # rmmod nvidia_uvm

rmmod: ERROR: Module nvidia_uvm is not currently loaded

reik-msi /home/reik # rmmod nvidia_modeset

rmmod: ERROR: Module nvidia_modeset is not currently loaded
```

I built Nvidia with UVM and KMS for bumblebee, so I need nvidia_drm, nvidia_uvm and nvidia_modeset.

Also I have nvidia as a module in /etc/conf.d/modules.

----------

## Naib

is xorg still running?

This is the bash alias I have to stop xorg, unload nvidia, reload nvidia, start xorg

```
alias nvidia="/etc/init.d/xdm stop && rmmod nvidia_drm && rmmod nvidia_modeset && rmmod nvidia && modprobe nvidia && /etc/init.d/xdm start"

```

----------

## reikdas

 *Naib wrote:*   

> is xorg still running?
> 
> This is the bash alias I have to stop xorg, unload nvidia, reload nvidia, start xorg
> 
> ```
> ...

 

When I ran that, since my display manager stopped, I was pushed out to tty and my display manager did not start back up, so I am not sure if the rest of the commands worked  :Sad: 

----------

## Dwosky

 *reikdas wrote:*   

> 
> 
> These are the errors I faced while trying to rmmod nvidia -
> 
> ```
> ...

 

You can use lsmod to list the modules but also to check what's their parent process or what process its stopping you from removing the module.

----------

## Naib

 *reikdas wrote:*   

>  *Naib wrote:*   is xorg still running?
> 
> This is the bash alias I have to stop xorg, unload nvidia, reload nvidia, start xorg
> 
> ```
> ...

 

this command shouldn't push you out to a tty because you need to be in a tty... IF you ran this from within Xorg (gnome,kde,openbox...) then ONCE xdm has stopped then you will go to a tty... Now maybe aspects of the rmmod started so that part of the drivers were removed BUT it wouldn#'t be able to complete because the terminal would have been killed

This is what you need todo 

1) CTRL-ALT-F1  to switch to a tty

2) login as root

3) execute etc/init.d/xdm stop && rmmod nvidia_drm && rmmod nvidia_modeset && rmmod nvidia && modprobe nvidia && /etc/init.d/xdm start (hence why I have this as an alias for root)

* xorg should stop, nvidia unloaded, nvidia loaded, xorg should start

Now if this fails there maybe some additionals associated with your setup (systemd as oppose to openrc, some additional drivers...) and if that is the case the steps would be

1) CTRL-ALT-F1  to switch to a tty

2) login as root

3) /etc/init.d/xdm stop

3) rmmod nvidia

*) check error message

4) lsmod

5) rmmod $some_other_module

...

----------

## Yamakuzure

As there are "sub"-modules now, like drm and uvm, "rmmod" is not the best idea.

Better to configure to use "modprobe -r" like reikdas did above.

Copy&Paste: (I am not on my laptop...)

```
$ cat nvidia-rmmod.conf 

# Nvidia UVM support 

remove nvidia modprobe -r --ignore-remove nvidia_drm nvidia_modeset nvidia_uvm nvidia
```

The crux is: 'rmmod" ignores this! Use 'modprobe -r nvidia' and it should just work.

----------

