When installing CUDA, how to determine distro,version and architecture parameters?
Solution 1:
If you use the CUDA downloads website and selected the appropriate options (say Linux, x86-64, Ubuntu, 16.04 in order), it will show the exact command you're supposed to run:
- The distro is Ubuntu (16.04 or 14.04 depending on what you're using, run
lsb_release -cd
to find out). - The version is based on the CUDA release you're downloading.
- For the architecture, see How to find architecture of my PC and Ubuntu? - use
uname -m
.
Solution 2:
The CUDA downloads site only reflects the latest version of CUDA. You should check the following as well:
- Recommended driver for your hardware. For me on Ubuntu 20.04, my RTX 3090 graphics card should use driver version 470. See the release notes, table 3 for the maximum corresponding CUDA version. In my case it's CUDA 11.4.x.
- The GCC required by your CUDA version. On Ubuntu 20.04, the default GCC is
9.x
, so my maximum CUDA version is11.4.0
(i did not want to install a newer GCC). - If you're using other packages that depend on a specific version of CUDA, check those as well (e.g the current latest Pytorch is compiled with CUDA 11.3).
- Note the driver version for your chosen CUDA: for
11.3.1
, the driver version is465.19.01
.
The downloads site tells me to use cuda-repo-ubuntu2004-11-6-local_11.6.0-510.39.01-1_amd64.deb
. I will change the versions accordingly:
Distro: ubuntu2004-11-6-local -> ubuntu2004-11-3-local
Version: 11.6.0-510.39.01-1 -> 11.3.1-465.19.01-1 (<CUDA version>-<driver version>)
Architecture: amd64 (no change)
So i change the downloads site output from:
wget https://developer.download.nvidia.com/compute/cuda/11.6.0/local_installers/cuda-repo-ubuntu2004-11-6-local_11.6.0-510.39.01-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu2004-11-6-local_11.6.0-510.39.01-1_amd64.deb
sudo apt-key add /var/cuda-repo-ubuntu2004-11-6-local/7fa2af80.pub
to
wget https://developer.download.nvidia.com/compute/cuda/11.3.1/local_installers/cuda-repo-ubuntu2004-11-3-local_11.3.1-465.19.01-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu2004-11-3-local_11.3.1-465.19.01-1_amd64.deb
sudo apt-key add /var/cuda-repo-ubuntu2004-11-3-local/7fa2af80.pub
If you've installed the wrong version (e.g. 11.6) and want to undo, you can use
sudo apt remove cuda
sudo dpkg remove cuda
sudo apt-key remove /var/cuda-repo-ubuntu2004-11-6-local/7fa2af80.pub
sudo rm /etc/apt/sources.list.d/cuda-ubuntu2004-11-6-local.list
sudo rm -r /usr/local/cuda-11.6
sudo rm /etc/alternatives/cuda /etc/alternatives/cuda-11