前面的cuda-toolkit-11-6安装成功的话安装 WSL2 + ubuntu18.04 + 511.65 + cuda-toolkit-11-6_敦码的博客-CSDN博客

接下来就是安装nvidia-docker,

1、首先安装 WSL2 Linux 发行版标准 Docker-CE,执行

curl https://get.docker.com | sh   

2、然后设置稳定的存储库和 GPG 密钥

distribution=$(. /etc/os-release;echo $ID$VERSION_ID)

curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -

curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list

3、更新软件包列表再安装 nvidia-docker2软件包

sudo apt-get update

sudo apt-get install -y nvidia-docker2

 4、重启docker服务

sudo service docker stop 

sudo service docker start

5、测试一下是否安装成功(这里选择N-body simulation CUDA sample)

docker run --gpus all nvcr.io/nvidia/k8s/cuda-sample:nbody nbody -gpu -benchmark

如果出现下面情况,说明安装成功了

踩坑日记:

1、如果出现 libnvidia-ml.so.1: cannot open shared object file: no such file or directory: unknown.

官方说是新版的bug, 需要手动修改 /etc/nvidia-container-runtime/config.toml的 "@/sbin/ldconfig",改成"/sbin/ldconfig",如果还没解决,可以对部分包进行降级,看这篇博客Windows系统WSL2 的ubuntu子系统安装 docker、nvidia-docker调用GPU_SUNbrightness的博客-CSDN博客

sudo apt-get install nvidia-docker2:amd64=2.5.0-1 \
           libnvidia-container-tools:amd64=1.3.3-1 \
           nvidia-container-runtime:amd64=3.4.2-1 \
           libnvidia-container1:amd64=1.3.3-1 \
           nvidia-container-toolkit:amd64=1.4.2-1

 

Logo

更多推荐