Skip to content

Instantly share code, notes, and snippets.

@atinfinity
Last active October 7, 2023 06:30
Show Gist options
  • Save atinfinity/f9568aa9564371f573138712070f5bad to your computer and use it in GitHub Desktop.
Save atinfinity/f9568aa9564371f573138712070f5bad to your computer and use it in GitHub Desktop.
Install NVIDIA Container Toolkit on WSL2

Install NVIDIA Container Toolkit on WSL2

Preparation

Please install Ubuntu on WSL2.
I have executed the following procedures on Ubuntu 22.04 of WSL2.

Install Docker CLI

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo gpasswd -a $USER docker
logout

Install 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

Restart Docker service

sudo systemctl restart docker

Running a Sample Workload with Docker

docker run -it --rm --gpus all nvidia/cuda:11.8.0-base-ubuntu22.04 nvidia-smi

Reference

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