NVIDIA-SMI has failed in Ubuntu 18.04

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.