Skip to content

Instantly share code, notes, and snippets.

@netbrain
Last active July 7, 2024 05:02
Show Gist options
  • Save netbrain/288ba07edee771f5c7fd086a0ea9f62e to your computer and use it in GitHub Desktop.
Save netbrain/288ba07edee771f5c7fd086a0ea9f62e to your computer and use it in GitHub Desktop.
Windows 11 + WSL + DOCKER + NVIDIA
# Setup WSL
wsl --update
wsl --install -d Debian
# Enter WSL
wsl
# Setup base system
sudo apt update
sudo apt install -y --no-install-recommends apt-transport-https ca-certificates curl gnupg2 vim
# Setup systemd support
sudo tee -a /etc/wsl.conf > /dev/null <<EOT
[boot]
systemd=true
EOT
exit
# Restart WSL
wsl --shutdown Debian
wsl
# Install docker
source /etc/os-release
curl -fsSL https://download.docker.com/linux/${ID}/gpg | sudo apt-key add -
echo "deb [arch=amd64] https://download.docker.com/linux/${ID} ${VERSION_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io
sudo usermod -aG docker $USER
# Install NVIDIA Container toolkit
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
&& 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/$distribution/libnvidia-container.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
sudo nvidia-ctk runtime configure --runtime=docker
# Test GPU
docker run --gpus all nvcr.io/nvidia/k8s/cuda-sample:nbody nbody -gpu -benchmark
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment