Question: I am trying to run this command: 

```
# rmmod nvidia

```

But I get:

```
ERROR: Module nvidia is in use

```

How can I know which process(es) is/are using the nvidia module?

Answer: 
There isn't a direct way that I know of to get the processes that are using a module.

You can try `lsmod | grep <module name>` to see all loaded kernel modules that are using a module.

You can also try `dmesg | grep <module name>` to see if the kernel logs have any clues as to which processes may be using a module.

You may be able to remove the module using `rmmod --force <module_name>`.

As for the nvidia module, you should be able to remove it if you shut down X11.

```
init 4
rmmod nvidia

```

worked for me.
For the nvidia module, this information can be retrieved by doing

```
$ sudo lsof /dev/nvidia*
[sudo] password for XXXXXXX: 
COMMAND     PID                USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
nvidia-pe 19360 nvidia-persistenced    2u   CHR 195,255      0t0  503 /dev/nvidiactl
nvidia-pe 19360 nvidia-persistenced    3u   CHR   195,0      0t0  504 /dev/nvidia0
nvidia-pe 19360 nvidia-persistenced    5u   CHR   195,0      0t0  504 /dev/nvidia0
nvidia-pe 19360 nvidia-persistenced    6u   CHR   195,0      0t0  504 /dev/nvidia0
nvidia-pe 19360 nvidia-persistenced    7u   CHR 195,254      0t0  513 /dev/nvidia-modeset
nvidia-pe 19360 nvidia-persistenced    8u   CHR   195,0      0t0  504 /dev/nvidia0
nvidia-pe 19360 nvidia-persistenced    9u   CHR   195,1      0t0  505 /dev/nvidia1
nvidia-pe 19360 nvidia-persistenced   10u   CHR   195,1      0t0  505 /dev/nvidia1
nvidia-pe 19360 nvidia-persistenced   11u   CHR   195,1      0t0  505 /dev/nvidia1
nvidia-pe 19360 nvidia-persistenced   12u   CHR 195,254      0t0  513 /dev/nvidia-modeset
nvidia-pe 19360 nvidia-persistenced   13u   CHR   195,1      0t0  505 /dev/nvidia1

```