Install CUDA 12 on PopOS

Published August 19, 2023 by Toran Billups

Yesterday I upgraded to the latest version of bumblebee only to learn EXLA took on the latest XLA which dropped support for CUDA 11.2.

Because I was running Pop!OS I assumed it would be something I could `apt install` and call it good. Unfortunately it was more work than my first go round so I wanted to detail it here for anyone who might follow. This is loosely based off the older CUDA 11 install instructions I found but updated for ubuntu 22.04.

Before you get started downloading anything, setup a developer account with nvidia so you can download cuDNN in a few minutes.

    $ wget
    $ sudo mv /etc/apt/preferences.d/cuda-repository-pin-600
    $ sudo apt-key adv --fetch-keys
    $ sudo add-apt-repository "deb /"
    $ sudo apt update
    $ sudo apt install cuda-toolkit-12-2

Next download cuDNN from nvidia and install it.

    $ sudo dpkg -i cudnn-local-repo-ubuntu2204-
    $ sudo cp /var/cudnn-local-repo-ubuntu2204- /usr/share/keyrings/
    $ sudo apt update
    $ sudo apt install libcudnn8=

Finally, set a few env variables and the correct XLA_TARGET for EXLA

    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
    export CUDA_HOME=/usr/local/cuda
    export PATH="/usr/local/cuda/bin:$PATH"
    export XLA_TARGET=cuda120
    export XLA_FLAGS=--xla_gpu_cuda_data_dir=/usr/local/cuda

Open a new terminal session and verify CUDA 12 is setup correctly by running this command

    nvcc -V

Buy Me a Coffee

Twitter / Github / Email