Installing CUDA &co

If you install the nvidia driver, it will choose the version of CUDA. That’s generally not ideal for TF. If you follow the NVIDIA instructions for CuDNN, it tells you to do the driver, then CUDA toolkit. But that only works if you want the latest version, which never works with anything…

To install a given version of CUDA (which installs the driver, so never install the nividia-driver directly!).

First, purge the existing driver (don’t skip steps and go directly to the CuDNN instructions!):

sudo apt-get --purge remove "*cuda*" "*nvidia*" "libxnvctrl*"
sudo apt-get autoremove
sudo reboot

Then, go on the nvidia site to “download a specific version of the cuda toolkit” and follow the instructions there. For example, for 11.8, https://developer.nvidia.com/cuda-11-8-0-download-archive easy to modify as needed. And… the CUDA instructions are correct and don’t instruct you to install the driver!

It will eventually make you install a .deb file, you can then update the repositories and just sudo apt-get install cuda. You reboot once more and CUDA is installed and the driver is loaded.

For CuDNN 8, you have to download a deb or tar file. For version 9, it can be installed with package manager… Here’s the archives of all previous versions https://developer.nvidia.com/rdp/cudnn-archive. You need an account to download the files.

Leave a Reply

Your email address will not be published. Required fields are marked *