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

My video drivers are not working. I cannot run cuda samples, with errors

[CUDA Mandelbrot/Julia Set] - Starting…
CUDA error at …/…/common/inc/helper_cuda.h:779 code=100(cudaErrorNoDevice) “cudaGetDeviceCount(&device_count)”

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

uname -a

Linux mazza-GE62VR-6RF 5.4.0-94-generic #106-Ubuntu SMP Thu Jan 6 23:58:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

gcc --version

gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal

nvidia-settings
ERROR: NVIDIA driver is not loaded
ERROR: Unable to load info from any available system

nvidia-bug-report.log.gz (153.0 KB)

1 Like

Oh goodness! You made an installer mess!
First: do not use the .run file installer, if there is not a good reason to. It even advises you not to use itself before installing!
Second: do not mix distro and .run file installations. Always remove either of them before using the other!
Third: If using the runfile installer, make sure to not use it, when X is still running!

Ok, lets try to clean up…

  • run sudo apt purge 'libnvidia*' 'nvidia*'

  • start the .run file installer again with the --uninstall parameter.

  • look for files blacklisting the nvidia driver: grep -r -e "blacklist.*nvidia$" /etc/modprobe.d /lib/modprobe.d - and delete them if found (sidenote: nvidiafb needs to be blacklisted).

  • run sudo apt install nvidia-driver-470 (or -495 as you wish) - watch the output closely, to look for errors.

  • check the dkms for success: dkms status|grep nvidia - should say “installed”.

  • run sudo prime-select nvidia or sudo prime-select on-demand (if you only want to render certain applications on the nvidia gpu (Chapter 34. PRIME Render Offload)

  • reboot.

It worked! thank you very much!

I’d like to add that there were also even more drivers I had to delete through

sudo dpkg -P libnvidia-compute-390 libnvidia-compute-495

To find out which ones I had to delete I ran

dpkg -l | grep nvidia

and

dpkg -S nvidia-smi

Also helped, because I could not find out which packages to delete (I could not delete nvidia-smi even after purging all my drivers through with apt remove --purge nvidia)

I really did a mess with my drivers but it now works, thanks!