- Remove old versions
- Add repository
- Install the specific version
- Add machine learning repository
Newer software is being compiled against CUDA 10.2. But some software I need to use requires CUDA 10.1 specifically. Well, my Ubuntu 18.04 box had CUDA 9.1. Lets walk through how to get your system upgraded from CUDA 9.1 to 10.1.
If you do this on different versions of Ubuntu, it should translate just fine, the only thing you need to do, is find the instances of 1804 in the nvidia URLs and replace them with your version to get the right debs for your install. There is also a pretty large list of supported distros.
Remove old versions
We need to go ahead and remove the old packages to avoid any conflicts.
sudo apt --purge remove "cublas*" "cuda*" sudo apt --purge remove libcudnn7 libcudnn7-dev libnccl2
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.0.130-1_amd64.deb sudo dpkg -i cuda-repo-ubuntu1804_10.0.130-1_amd64.deb sudo apt update
note: if the deb no longer exists(depending on when you are reading this), just visit the URL and look for cuda-repo-ubuntu1804-*.deb
Install the specific version
Lets see what versions are available:
$ sudo apt-cache showpkg cuda | grep 10.1 10.1.243-1 (/var/lib/apt/lists/developer.download.nvidia.com_compute_cuda_repos_ubuntu1804_x86%5f64_Packages) (/var/lib/dpkg/status) 10.1.168-1 (/var/lib/apt/lists/developer.download.nvidia.com_compute_cuda_repos_ubuntu1804_x86%5f64_Packages) 10.1.105-1 (/var/lib/apt/lists/developer.download.nvidia.com_compute_cuda_repos_ubuntu1804_x86%5f64_Packages) 10.1.243-1 - cuda-10-1 (2 10.1.243) 10.1.168-1 - cuda-10-1 (2 10.1.168) 10.1.105-1 - cuda-10-1 (2 10.1.105) 10.1.243-1 - 10.1.168-1 - 10.1.105-1 - $ sudo apt -y install cuda=10.1.243-1 [...]
As you can see, there are a few versions of 10.1 available. I am going to go with 10.1.243-1. To select it in your apt install command you just set it equal to the version. If you want 10.2(latest at the time of writing) simply leave off the equals part.(eg:
apt -y install cuda) This will tell apt to install the latest version it can find. But for my needs, I specifically need a 10.1 version.
Add machine learning repository
Some software, tensorflow for example, requires cuDNN, and a few other things. So lets go ahead and add the machine learning repository while we are under the hood.
wget https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb sudo dpkg -i nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb sudo apt update
Now we need to get lubcudnn7, and libnccl2. Use
apt-cache showpkg ... like earlier to find the version you need to work with CUDA 10.1. (or 10.2 if you went with latest)
sudo apt install libcudnn7-dev=220.127.116.11-1+cuda10.1 libcudnn7=18.104.22.168-1+cuda10.1 libnccl2=2.5.6-1+cuda10.1
There aren’t many reasons to need to reboot a linux machine, but this is one of them. The easiest way to load the new driver is to reboot. As long as everything went okay, and there were no crazy errors, go ahead and reboot. If things went sideways, you likely wont be able to get video if you are plugged into the GPU directly. Move back to the onboard to troubleshoot. Good luck!