NVIDIA-SMI has failed in Ubuntu 18.04


I have updated my OS and tried to update my Nvidia drivers and toolkit following these commands:

However, when I try nvidia-smi, I get the error below. Can anyone help to figure out what is going on and how it can be fixed?

The error:

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

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

Please run nvidia-bug-report.sh as root and attach the resulting .gz file to your post. Hovering the mouse over an existing post of yours will reveal a paperclip icon.

Thanks for answer, I have run the nvidia-bug-report.sh and have attached the file. Thanks.

Looks like you somehow lost your gcc so the kernel module can’t be compiled. Please reinstall it using
sudo apt install gcc
and check that it’s there
gcc -v
Then purge and reinstall the nvidia driver. Afterwards, don’t install cuda, instead use
sudo apt install cuda-toolkit-10-0
otherwise you would overwrite the driver with an older version.

I do have gcc on my machine it. it is in etc folder. when I try to gcc -v, it tells me command gcc not found but can be installed with: sudo apt install gcc.

When I try to execute sudo apt install gcc, it tells me that the gcc is already the newest version.

/etc is a config folder only. Reinstall gcc using
sudo apt install --reinstall gcc

nvidia-bug-report.log.gz (75.5 KB)
I have the same problem, but ubuntu 20.04.
actually, I want to run steam`s games on the nvidia gpu, but linux run them only by integrated Intel HD Graphics. (I have laptop)