Unable to properly install/uninstall Cuda on Ubuntu 18.04

You probably have some pending upgrades from apt. Do the update and upgrade first and then install cuda-10-1.
Otherwise, it means you manually installed a package that is in the dependencies of cuda but in a version not supported (gcc, libopencl, nvidia-drivers, …).

I just upgrade from 16.04 to 18.04 and have the same problem.
It might because of old dependencies that related to cuda.
I’ve try these things and it works.

sudo apt-get autoremove
sudo apt-get update
sudo apt-get install cuda

The CUDA 10.1 release notes also specify :

Hi,
Just like @kriegalex said, this issue occurs on fresh installed Ubuntu 18.04.2. The problem is the package “xserver-xorg-video-nvidia-418_418.39-0ubuntu1_amd64.deb” requires “xserver-xorg-core”, but the actual package installed natively on Ubuntu 18.04.2 is named “xserver-xorg-core-hwe-18.04”. If you choose to install “xserver-xorg-core” manually, it will uninstall gnome-desktop if you are using desktop edition which is not acceptable.

I temporarily solved it like this:

  1. Download the local install tar.gz file and extract it.
  2. Extract xserver-xorg-video-nvidia-418_418.39-0ubuntu1_amd64.deb file by “dpkg -x” and “dpkg -e”
  3. Modify the “control” file in extracted package, remove the dependency on “xserver-xorg-core” and “xorg-video-*”
  4. Rebuild the debian package via command “dpkg -b”
  5. Run following command:
    apt-get install libnvidia-cfg1
    dpkg -i xserver-xorg-video-nvidia-418_418.39-0ubuntu1_amd64.deb
    apt-get install cuda

Reference: Leonard's Blog: Ubuntu: Modify the Dependency of a package (*CAUTION* THIS MAY BREAK THE SYSTEM UNINTENTIONALLY)

1 Like

do…
sudo apt-get install build-essential dkms
sudo apt-get install freeglut3 freeglut3-dev libxi-dev libxmu-dev

before…

sudo apt-get install cuda

greetings

2 Likes

I am encountering this issue for the second time now, with my GPUs (2x Geforce GTX 1080 Ti) not recognized.

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

Last time I was able to resolve the issue using essentially the procedure outlined by kopkop, #24 (thanks!!). The only real difference was

$apt-get install libnvidia-cfg1

didn’t seem to work, so I checked for available packages on https://packages.ubuntu.com/; currently the most recent is libnvidia-cfg1-418.
Now, the second time I’m encountering this issue, the same method fails to work. In fact, I think I’ve tried almost all the methods suggested above that seemed applicable (I also tried the local, network and runfile installations). I start each new installation attempt with

$sudo apt-get purge nvidia* 
$sudo apt-get remove --purge '^nvidia-.*'
sudo apt-get --purge remove cuda*

Please note that in neither case of the error appearing was it related to an OS upgrade; I do believe it was following some update/reboot in both cases, though. I upgraded to Ubuntu 19.04 (Disco) several months ago; the last time I fixed the issue, it was 18.04.
With reference to #14, who posted that /var/ might contain an older cuda repo, I have verified that my purge/remove commands leave no trace behind. Currently, I only have /var/cuda-repo-10-1-local-10.1.243-418.87.00 following my last installation attempt of Nvidia 418.87. I got no errors on my last installation, but as stated, my GPUs are not recognized. Any and all help would be greatly appreciated.

Brother… You are a life saver… Thank you

Oh my life saver lolol!!!

I am less than impressed with the level of support from Nvidia and this product. The error encountered during an install are not very intuitive. I have been exchanging emails with someone from Nvidia for over a week without a resolution.

1 Like

love you :*

Thanks! helped with CUDA 11 upd 1 and Ubuntu 18.04