Docker support for NVIDIA GPU Accelerated Computing on WSL 2

Docker support for NVIDIA GPU Accelerated Computing on WSL 2

  • 0. 背景
  • 1. 安装 Docker Desktop
  • 2. 配置 Docker Desktop
  • 3. WLS Ubuntu 配置
  • 4. 安装 Docker-ce
  • 5. 安装 NVIDIA Container Toolkit
  • 6. 配置 Docker
  • 7. 运行一个 Sample Workload

0. 背景

今天尝试一下 NVIDIA GPU 在 WSL-Ubuntu 系统里面对 Docker 的支持情况。

1. 安装 Docker Desktop

访问 https://www.docker.com/products/docker-desktop/,下载并安装 Docker Desktop。

Docker support for NVIDIA GPU Accelerated Computing on WSL 2_第1张图片

2. 配置 Docker Desktop

具体配置项目请参考截图,

Docker support for NVIDIA GPU Accelerated Computing on WSL 2_第2张图片
Docker support for NVIDIA GPU Accelerated Computing on WSL 2_第3张图片

实际上最终这里不勾选任何项目

3. WLS Ubuntu 配置

vi /etc/wsl.conf

---
[boot]
systemd = true
---

4. 安装 Docker-ce

refer: https://docs.docker.com/engine/install/ubuntu/

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

5. 安装 NVIDIA Container Toolkit

refer: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html

运行下面命令,安装 NVIDIA Container Toolkit,

curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
  && curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
    sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
    sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit

6. 配置 Docker

sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker

7. 运行一个 Sample Workload

sudo docker run --rm --runtime=nvidia --gpus all ubuntu nvidia-smi

Docker support for NVIDIA GPU Accelerated Computing on WSL 2_第4张图片
完结!

你可能感兴趣的:(LINUX,docker,Nvidia,GPU,WSL-Ubuntu)