Problem while installing cuda toolkit in ubuntu 18.04

I just ran into this issue and solved it by running the following commands:

sudo apt clean
sudo apt update
sudo apt purge nvidia-* 
sudo apt autoremove
sudo apt install -y cuda

Major thanks to this post on the Nvidia forums.


I think the issue is the CUDA driver version. It looks like the installer tries to install the newest version 455.23.05 and the installation actually fails there.

I've solved it by first downloading the local installer and unselecting the CUDA driver installation, so it just installs the toolkit.

wget https://developer.download.nvidia.com/compute/cuda/11.1.0/local_installers/cuda_11.1.0_455.23.05_linux.run
chmod +x cuda_11.1.0_455.23.05_linux.run 
sudo ./cuda_11.1.0_455.23.05_linux.run 

In the menu unselect the driver installation: enter image description here If not already done, add the nvidia repo as per instructions from the official website before installing the driver:

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /"
sudo apt-get update

Install the CUDA driver 450 manually:

sudo apt-get install cuda-drivers-450

Test by running nvcc -V In case nvcc is not found, don't forget to add it to your PATH: PATH=$PATH:/usr/local/cuda/bin


You have to uninstall any nvidia driver before running sudo apt install -y cuda
To do so, got to "Software & Updates" -> "Additional drivers" -> Using X.Org X (nouveou)