I went deep in the rabbit hole on this one, so I'd like to help anyone who experiences the same problem.
This question is very similar to this one and both the answers are helpful, albeit at the time of writing this post, none of them is accepted.
The answer is well described here and here. The most important thing is that when you are installing the drivers, and later, while using them, SecureBoot MUST be disabled.
Step By Step Guide
You need to (step by step):
- (optional) To start clean, you can purge all configs you tried to install so far:
sudo apt purge '^.*nvidia*'
sudo apt install ubuntu-desktop
sudo apt purge "^.*cublas*"
sudo apt purge "^.*cuda*"
sudo mv /etc/X11/xorg.conf /etc/X11/xorg.conf.old
sudo apt autoremove
- Reboot, and disable
SecureBoot
in the bios. That's extremely important, otherwise the drivers won't load
- After
SecureBoot
is disabled, then you run the following commands:
sudo ubuntu-drivers devices
sudo ubuntu-drivers autoinstall
reboot
- once you reboot, you can verify that your drivers are working by issuing:
nvidia-smi
Verify Working Drivers
If your drivers are working, when you issue nvidia-smi
you are going to get some output like:
Sat Nov 13 17:02:26 2021
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.82.00 Driver Version: 470.82.00 CUDA Version: 11.4 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... Off | 00000000:01:00.0 Off | N/A |
| N/A 50C P8 2W / N/A | 9MiB / 3914MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 1484 G /usr/lib/xorg/Xorg 4MiB |
| 0 N/A N/A 2041 G /usr/lib/xorg/Xorg 4MiB |
+-----------------------------------------------------------------------------+
Not Working Drivers
If something went wrong, you are going to see something like:
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.