Problem with installing CUDA Toolkit on Ubuntu 21.10

Solution 1:

I solved it by the following process.

sudo apt purge cuda*
sudo apt purge nvidia*
sudo apt purge libnvidia*
sudo apt autoremove

Removing all the stuff regarding nvidia is mandatory, otherwise you might face some installation issues.

I found that my supported nvidia driver is nvidia-driver-418 from nvidia driver downloads, later I found that ubuntu nvidia-driver-418 has been moved to nvidia-driver-470 (470.82.01), I don't know the theory behind this.

Then from NVIDIA CUDA Toolkit Release Notes I got that CUDA 11.4 Update 3 ships with nvidia-driver-470 (470.82.01) and it's done. Then simply I followed the process from official documentation for local deb (Ubuntu 21.10 isn't available there but 20.04 works), and it worked.

In my case it was like:

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/11.4.3/local_installers/cuda-repo-ubuntu2004-11-4-local_11.4.3-470.82.01-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu2004-11-4-local_11.4.3-470.82.01-1_amd64.deb
sudo apt-key add /var/cuda-repo-ubuntu2004-11-4-local/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda