参考:https://blog.csdn.net/fleaxin/article/details/108911522
cd \
&& echo "修改源" \
&& sed -i "s/archive.ubuntu/mirrors.aliyun/g;s/security.ubuntu/mirrors.aliyun/g" /etc/apt/sources.list \
&& apt-get update \
&& echo "安装cuda-11" \
&& wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin \
&& mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600 \
&& wget https://developer.download.nvidia.com/compute/cuda/11.1.0/local_installers/cuda-repo-wsl-ubuntu-11-1-local_11.1.0-1_amd64.deb \
&& dpkg -i cuda-repo-wsl-ubuntu-11-1-local_11.1.0-1_amd64.deb \
&& apt-key add /var/cuda-repo-wsl-ubuntu-11-1-local/7fa2af80.pub \
&& apt-get update \
&& apt-get -y install cuda \
&& echo "安装docker" \
&& curl https://get.docker.com | sh \
&& echo "安装nvidia-docker2" \
&& distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
&& curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | apt-key add - \
&& curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | tee /etc/apt/sources.list.d/nvidia-docker.list \
&& curl -s -L https://nvidia.github.io/libnvidia-container/experimental/$distribution/libnvidia-container-experimental.list | sudo tee /etc/apt/sources.list.d/libnvidia-container-experimental.list \
&& apt-get update \
&& apt-get install -y nvidia-docker2 \
&& service docker stop \
&& service docker start \
&& echo "测试" \
&& docker run --rm --gpus all nvcr.io/nvidia/k8s/cuda-sample:nbody nbody -gpu -benchmark