WSLにCUDAをインストール Ubuntu 20.04 CUDA 11.7

CUDAのインストールは以下を参考に進めればOK。

CUDA on WSL :: CUDA Toolkit Documentation

ただし、以下のようなエラーが発生する場合がある。

$ sudo apt update
Get:1 file:/var/cuda-repo-wsl-ubuntu-11-7-local  InRelease [1575 B]
Get:1 file:/var/cuda-repo-wsl-ubuntu-11-7-local  InRelease [1575 B]
Err:1 file:/var/cuda-repo-wsl-ubuntu-11-7-local  InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY BCD50790B81839D3

その時は、以下のコマンドを打てばOK。

$ sudo cp /var/cuda-repo-wsl-ubuntu-11-7-local/*.gpg /usr/share/keyrings/

参考: nvidia - Unable to install CUDA on Ubuntu 22.04 WSL2 - Ask Ubuntu