Nvidia-smi not working on dual-booted Ubuntu 20.04

Problem description

On my laptop, I have a dualboot with windows 11 and ubuntu 20.04. On ubuntu, I’ve tried to plug in a second monitor through an HDMI cable, but there was no image showing on the second monitor.
First, my laptop was able to discover the monitor in Activities->Displays menu, but after trying to fix the issue I’ve actually made things worse, where the monitor wasn’t even shown.
After some searching I encountered there were some problems with my nvidia drivers (my graphics cards can be seen from the output of):

sudo lspci | grep 'VGA'
01:00.0 VGA compatible controller: NVIDIA Corporation GA106M [GeForce RTX 3060 Mobile / Max-Q] (rev a1)
05:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Cezanne [Radeon Vega Series / Radeon Vega Mobile Series] (rev c6)

Nvidia-smi not working

When i try:

nvidia-smi

The error message is:

NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

What I’ve tried to fix it

I’ve already tried many things to reinstall/update/configure my nvidia drivers, including:

Updating to latest version of nvidia-drivers:

The output of ubuntu-drivers devices is:

== /sys/devices/pci0000:00/0000:00:01.1/0000:01:00.0 ==
modalias : pci:v000010DEd00002560sv000017AAsd00003A80bc03sc00i00
vendor   : NVIDIA Corporation
driver   : nvidia-driver-525-server - distro non-free
driver   : nvidia-driver-525 - distro non-free
driver   : nvidia-driver-535 - distro non-free
driver   : nvidia-driver-535-server - distro non-free
driver   : nvidia-driver-535-open - distro non-free
driver   : nvidia-driver-470 - distro non-free
driver   : nvidia-driver-525-open - distro non-free
driver   : nvidia-driver-470-server - distro non-free
driver   : nvidia-driver-535-server-open - distro non-free recommended
driver   : xserver-xorg-video-nouveau - distro free builtin

So I’ve tried to install the correct drivers using:

  • $ sudo ubuntu-drivers autoinstall
  • $ sudo apt install nvidia-driver-535-server-open (the recommended option)
  • Completely purging and reinstalling nvidia drivers using:
sudo apt-get purge nvidia-*
sudo apt-get update
sudo apt-get autoremove

And after that:

sudo apt install libnvidia-common-470
sudo apt install libnividia-gl-470
sudo apt install nvidia-driver-470
  • Other attempts such as trying to remove a file in /etc/modprobe.d/ or /lib/modprobe.d/ that contains blacklist on nvidia
  • Trying to disable secure boot following these commands:
  1. sudo apt install nvidia-driver-470
  2. sudo reboot
  3. sudo apt install nvidia-cuda-toolkit

This actually shed light onto perhaps an even bigger problem - mokutil not working. After I’ve tried to get secure boot status using $ sudo mokutil –sb-state, the process simply aborted.
Anyway, none of these attempts have worked.

I don’t know why Ubuntu would recommend the -open server driver, but it’s definitely the wrong one.

Will install exactly that from above.

That would be the legacy version of the driver.

Either of those two you should choose.

sudo apt purge '*nvidia*'
sudo apt install linux-headers-$(uname -r)
sudo apt install nvidia-driver-535

dkms status should then show the driver as ‘installed’.
Reboot.
If nvidia-smi still doesn’t work, run sudo nvidia-bug-report.sh and attach the resulting file here.

Might be a forum software formatting thing:
mokutil --sb-state (double dash) is the correct command.

Otherwise, that’s something to talk with Ubuntu about.

1 Like

Hi, thanks alot for your answer :)
While trying to apply your solution, I encountered another problem. After purging nvidia, I tried to install linux headers:
sudo apt install linux-headers-$(uname -r)
The error message:
‘E: Package ‘linux-headers-5.18.3-051803-generic’ has no installation candidate’

After searching for this error on the web, the only result that came out was something about updating kernel, which I did. The only result that brought was changing the error message to:
E: Package 'linux-headers-6.4.8-060408-generic' has no installation candidate
(‘6.4.8-060408-generic’ is the output of my uname -r)
Do you have any idea how could I solve this?
I am very new to using linux.
Also, since I’ve purged nvidia I can’t send my nvidia-bug-report yet, and you were right, mokutil --sb-state worked as expected :)

These are mainline kernels. They are not compatible with Ubuntu 20.04. Remove the mainline PPA.
If you need a newer kernel for your hardware, you could use this ppa:

1 Like

Hi again, I uninstalled the 6.4.8 kernel and used TuxInvade’s ppa to get 6.3.13 kernel. Followed your commands and everything worked! Nvidia-smi showed the correct output and my second monitor works :)

Thanks a lot for your help! Have a good day

Good!
Please mark my answer as solution.
Thanks and a good day to you too!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.