Skip to content

Instantly share code, notes, and snippets.

@jlmelville
Last active September 5, 2022 17:28
Show Gist options
  • Save jlmelville/d236b6eafb3067bfdac304274dc5cf83 to your computer and use it in GitHub Desktop.
Save jlmelville/d236b6eafb3067bfdac304274dc5cf83 to your computer and use it in GitHub Desktop.
Fixing the legacy gpg keyring warning when installing CUDA on Ubuntu for WSL2

Ubuntu, CUDA, WSL2 and legacy keyrings

In the Ubuntu tutorial on enabling CUDA with WSL2, and specifically in part 3, you are directed to use apt-key to point Ubuntu at the correct toolkit package. On Ubuntu 22.04 this will lead to the following warning whenever you run apt-get update:

 Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.

To fix this, follow the instructions at Ask Ubuntu. Here are those instructions tailored for the cudatools installation:

  1. List the keys

    sudo apt-key list
  2. Look for the section that mentions cudatools:

    /etc/apt/trusted.gpg
    --------------------
    pub   rsa4096 2022-04-14 [SC]
          EB69 3B30 35CD 5710 E231  E123 A4B4 6996 3BF8 63CC
    uid           [ unknown] cudatools <cudatools@nvidia.com>
    
  3. Export the key by taking the last 8 characters from the pub section without the space:

    sudo apt-key export 3BF863CC | sudo gpg --dearmour -o /usr/share/keyrings/nvidia.gpg
  4. Edit the apt source list that points to the nvidia repo, mine was at: /etc/apt/sources.list.d/archive_uri-https_developer_download_nvidia_com_compute_cuda_repos_wsl-ubuntu_x86_64_-jammy.list. Add a [signed-by=/usr/share/keyrings/nvidia.gpg] tag to the deb entry:

    deb [signed-by=/usr/share/keyrings/nvidia.gpg] https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/ /
    

On next update, the warning will be gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment