Unsloth Docker on WSL2 (Debian Trixie)
Created: 2026-03-13 17:35:13 | Last updated: 2026-03-16 14:25:16 | Status: Public
1. Add the NVIDIA Container Toolkit repo
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
2. Install the toolkit
export NVIDIA_CONTAINER_TOOLKIT_VERSION=1.17.8-1
sudo apt-get update && sudo apt-get install -y \
nvidia-container-toolkit=${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
nvidia-container-toolkit-base=${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
libnvidia-container-tools=${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
libnvidia-container1=${NVIDIA_CONTAINER_TOOLKIT_VERSION}
If apt throws a signature error, add
--allow-insecure-repositoriesto theapt-get updatecall. This is a known Debian Trixie issue with NVIDIA’s SHA1-signed repo as of Feb 2026.
3. Configure Docker to use the NVIDIA runtime
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
4. Verify GPU passthrough
docker run --rm --gpus all nvidia/cuda:12.3.0-base-ubuntu22.04 nvidia-smi
You should see your GPU listed with full VRAM. If this fails, stop here - the container won’t see the GPU either.
5. Stop any running containers
docker stop $(docker ps -q)
6. Run Unsloth
docker run -d \
-e JUPYTER_PASSWORD="yourpassword" \
-e JUPYTER_PORT=8888 \
-p 8888:8888 -p 2223:22 \
-v $(pwd)/work:/workspace/work \
--gpus all \
unsloth/unsloth
Port 2222 may be in use by another service. 2223 is the safe alternative for SSH.
Change the password.
7. Access Jupyter Lab
Open in your Windows browser: http://localhost:8888
Fix (2026-03-13)
pip install --upgrade --force-reinstall --no-cache-dir --no-deps unsloth unsloth_zoo
pip install "numpy<2.0" --force-reinstall
import unsloth
print(unsloth.__version__)
These are for allowing the traefik routing / LAN access
netsh interface portproxy add v4tov4 listenport=8888 listenaddress=0.0.0.0 connectport=8888 connectaddress=172.31.81.80
netsh advfirewall firewall add rule name="WSL2 Jupyter 8888" dir=in action=allow protocol=TCP localport=8888
Notes
- There is only one Unsloth image:
unsloth/unsloth. Works for all current GPU generations including Blackwell/50-series. - Always mount a work volume or your files disappear when the container stops.
- The container runs as a non-root
unslothuser. UseUSER_PASSWORDenv var if you need sudo inside the container. - SSH into the container (optional):
ssh -i ~/.ssh/container_key -p 2223 unsloth@localhost