Which local Kubernetes can run GPU work on WSL2
There are many ways to run models locally. This post tests seven local Kubernetes options against one GPU probe to find the best one for running GPU inference workloads on my machine.
- gpu
- 1 × RTX 5060, 8 GB, the one on my desk
- available
- desktop share not measured for this run
- cost
- $0 · one machine, one day
Every GPU harness and inference workload on this blog is going to run as a pod, so before writing any of them I needed a Kubernetes cluster on this machine that can actually use the GPU. It is a Windows desktop with an RTX 5060, and everything Linux runs in WSL2WSL2 A real Linux kernel running in a lightweight VM on Windows. The GPU reaches it through /dev/dxg, a paravirtualised device, rather than a native NVIDIA driver. Glossary. There are plenty of local Kubernetes options and most of them say they support GPUs, so rather than pick one and hope, I tested them: plain Docker as a control, then k3s, k3d, kind, minikube, Rancher Desktop and Docker Desktop in both its modes. One at a time, against the same probe, with the machine cleaned back to a blank slate between each.
1. Requirements
The cluster had to:
- run a pod that does real CUDA work on the GPU, not just one that can see it;
- let the scheduler ration the card, so a pod asks for the GPU and the next one waits instead of sharing it by accident;
- run GPU pods without
privileged: trueif at all possible; - start quickly from nothing and stay light, since it shares the machine with everything else I do.
Out of scope: more than one node, more than one GPU, and sharing the card between pods with MPSMPS Lets kernels from several processes run on the GPU at the same time instead of in turns, which wastes less of it than time-slicing. Isolation is still limited. Glossary or time-slicingtime-slicing A device plugin setting that advertises one GPU as several nvidia.com/gpu, so pods share it by taking turns. There's no memory isolation, so one pod can still take all of it. Glossary. Those get their own post.
What counts as working. I wrote the rules down before running anything. Every candidate ran the same probe image, built once and loaded by its image ID. The probe climbs five levels and reports the highest one it reached:
| Level | Meaning |
|---|---|
| 10 | nothing |
| 20 | NVML initialised, so the driver is reachable |
| 30 | a CUDA context |
| 40 | a 2 GiB allocation |
| 50 | a GEMM ran and every element of the result checked out |
Only 50 counts. nvidia-smi printing a device name is level 20, and a pod at Running proves nothing at all.
Running with nvidia.com/gpu: 1 and no driver in it is not a GPU pod. It is a pod.Separately, each Kubernetes candidate was scored on whether nvidia.com/gpu becomes allocatable, because a GPU that only works when a pod goes around the scheduler is a different thing from one Kubernetes can hand out.
Stock and tuned are separate results, and tuning got 45 minutes per candidate. Each candidate was its own step, and it was removed at the end of it, with the machine checked against the blank slate before the next one started. The tables below number the steps the same way: 01 the instrument, 02 the Docker ladder, 03 k3s, 04 k3d, 05 kind, 06 minikube, 07 Rancher Desktop, 08 Docker Desktop in kind mode and 08b in kubeadm mode.
2. Expectations
From what I had read, and from an earlier attempt with minikube, I went in fairly sure of three things:
- The GPU doesn’t survive container nesting on WSL2. So anything that runs its Kubernetes nodes as containers, like kind, k3d and minikube, can’t do GPU work here. That minikube attempt had
nvidia-smiworking inside the node container, and I put it down to luck. - A container needs three things to reach the GPU. It needs four.
- minikube fails because of a limit in NVMLNVML NVIDIA's C library for reading a GPU's memory, utilisation, power and clocks. nvidia-smi and most monitoring tools are built on it, and my harnesses call it from Python through nvidia-ml-py. Glossary. It fails because one directory is missing.
All three turned out to be wrong, and I would have ruled out kind and k3d without ever running them.
3. Measuring VRAM
Every VRAMVRAM The GPU's own memory. The RTX 5060 has 8 GB of GDDR7, and the model's weights, its KV cache and whatever the desktop draws all have to fit in it. Glossary number on this blog will be a whole-card before and after, because nothing on WSL2 can tell you how much a single process uses. Windows lists the processes on the GPU and reports [N/A] for every one of them; WSL2 and pods don’t list them at all. So before measuring anything else, I measured the noise.
Thirty samples of memory.used, two seconds apart, at the start of every step:
| Step | When | Median | IQR | Spread |
|---|---|---|---|---|
| 01 instrument | live | 2265 | 0 | 1 |
| 02 Docker ladder | live | 2284 | 2 | 10 |
| 03 k3s | pre-install | 2327 | 2 | 3 |
| 04 k3d | pre-install | 2323 | 8 | 39 |
| 05 kind | pre-install | 2263 | 1 | 2 |
| 06 minikube | pre-install | 2190 | 2 | 2 |
| 07 Rancher Desktop | pre-install | 2336 | 1 | 2 |
| 08 Docker Desktop | pre-enable | 2237 | 3 | 3 |
The noise floor at the start of each step, in MiB. Spread is max minus min: the smallest difference the step could see.
The floor moved between 1 and 39 MiB depending on what the desktop was doing. Against that, a known 2048 MiB allocation read as 2048 to 2050 MiB, and a CUDA contextCUDA context The state the driver sets up the first time a process uses CUDA. It takes GPU memory before the program allocates anything, about 113 MiB on this card. Glossary on its own cost 113 MiB. So the instrument works, and anything smaller than the floor is a “can’t tell”, not a number. That rule mattered later: none of the seven clusters held any VRAM at idle, and every reading stayed inside its floor.
To check a difference of your own against a floor, use the lab’s noise floor tool.
4. What a container needs
WSL2 has no NVIDIA kernel driver. Everything goes through the Windows driver, reached through a paravirtual device, and a container gets the GPU only when four things arrive together:
| What | What you see without it |
|---|---|
/dev/dxg |
NVML fails, or CUDA finds no device |
/usr/lib/wsl/lib, on the loader path |
libnvidia-ml.so.1: cannot open shared object file (exit 127) |
/usr/lib/wsl/drivers, the Windows driver store the libraries in lib load their code from |
nvml_init: Unable to load the NVML library |
| something that puts them there: the NVIDIA runtime, or mounts by hand | any of the above |
A container on WSL2 with nothing passed in. The probe can't even start: libnvidia-ml.so.1 is missing, exit 127.
/dev/dxg, the paravirtual GPU device, arrives. Still exit 127: there is no library to talk to it.
/usr/lib/wsl/lib arrives, on the loader path. NVML loads and then fails with Unable to load the NVML library: level 10.
/usr/lib/wsl/drivers, the driver store the libraries load their code from. Level 50: a verified GEMM.
The fourth thing is whatever puts the three there: the NVIDIA runtime, or mounts by hand. Miss one and the error points somewhere else.
The third one is the one I didn’t know about. With only the device and lib, the probe stops at level 10 with “Unable to load the NVML library”, which reads like a broken driver and isn’t.
5. The Docker ladder
Before any Kubernetes, I wanted to know whether the GPU survives a container inside a container, because kind, k3d and minikube are exactly that: the node is a container, and the pod is a container inside it. So I built a ladder in plain Docker, ten rungs from no GPU at all up to a Docker daemon inside a privileged container running another container. Each rung ran three times, and all ten gave the same answer every time.
One level deep, docker run --gpus all works: level 50.
Inside a Docker-in-Docker daemon, --gpus fails: the inner daemon has no NVIDIA runtime of its own.
Passing the mounts to the inner container doesn't help. --gpus gave the outer one individual files, not the folders, so there is nothing to pass down: exit 127.
By hand instead: /dev/dxg, /usr/lib/wsl/lib and /usr/lib/wsl/drivers, with the loader path set. Level 50, with no NVIDIA toolkit anywhere.
Passed down again, the same three work one level deeper. Level 50 at every depth I tried.
The GPU survives nesting; --gpus doesn't. So every cluster whose nodes are containers fails stock, and can be fixed with mounts.
| Rung | Outer container | Inner container | Level | Error |
|---|---|---|---|---|
| L1none | docker run (NVIDIA_VISIBLE_DEVICES=void) | none | libnvidia-ml.so.1: cannot open shared object file (exit 127) | |
| L1 | docker run --gpus all | 50 | ||
| L1m | docker run --device /dev/dxg + /usr/lib/wsl/lib + LD_LIBRARY_PATH | 10 | nvml_init: Unable to load the NVML library | |
| L1md | L1m + /usr/lib/wsl/drivers | 50 | ||
| L2none | docker:28-dind --privileged --gpus all | docker run | none | libnvidia-ml.so.1: cannot open shared object file (exit 127) |
| L2 | docker:28-dind --privileged --gpus all | docker run --gpus all | none | could not select device driver "" with capabilities: [[gpu]] |
| L2m-gpus | docker:28-dind --privileged --gpus all | L1m's flags | none | libnvidia-ml.so.1: cannot open shared object file (exit 127) |
| L2m-mounts | docker:28-dind --privileged + /dev/dxg + /usr/lib/wsl/lib | L1m's flags | 10 | nvml_init: Unable to load the NVML library |
| L2md-gpus | docker:28-dind --privileged --gpus all | L1md's flags | none | libnvidia-ml.so.1: cannot open shared object file (exit 127) |
| L2md-mounts | docker:28-dind --privileged + /dev/dxg + lib + drivers | L1md's flags | 50 |
The nesting ladder. Level is the probe's highest level; none means it didn't start.
--gpus all works one level deep and no further. It mounts individual files rather than the directories, so the container it starts has nothing to pass down. A Docker daemon inside it has no NVIDIA runtime of its own, and asking it for --gpus fails with could not select device driver "" with capabilities: [[gpu]].
The device and the two directories, passed down by hand with the loader path set, work at every depth I tried, with no NVIDIA toolkit involved anywhere. So the GPU does survive nesting on WSL2. What doesn’t nest is --gpus.
That predicted every container-node cluster that followed: each one fails stock, and each one can be fixed with mounts.
6. Candidates
| Candidate | Stock | Tuned | Rationed | Privileged pods | Unasked pod gets GPU |
|---|---|---|---|---|---|
| plain Docker (control) | 50 | 50 | n/a | no | n/a |
| k3s | 50 | 50 | yes | no | yes |
| k3d | none | 50 | yes | yes | no |
| kind | none | 50 | yes | yes | no |
| minikube | 10 | 50 | yes | no | yes |
| rancher-desktop | 50 | 50 | yes | yes | no |
| docker-desktop-kind | none | 50 | yes | yes | no |
| docker-desktop-kubeadm | 50 | 50 | yes | yes | no |
Probe level a pod reaches, stock and tuned. Stock is the install as documented; tuned is the least I had to change to reach level 50 with the GPU rationed.
the full table: how each one gets there
| Candidate | Version | The node is | Stock level | Stock, how | Tuned route | A pod that never asks for the GPU | Repeats |
|---|---|---|---|---|---|---|---|
| plain Docker (control) | Docker Desktop 4.88.1 | container (control) | 50 | --gpus all | device + /usr/lib/wsl/lib + /usr/lib/wsl/drivers + LD_LIBRARY_PATH (no toolkit) | n/a | 3 of 3 runs identical |
| k3s | k3s v1.36.5+k3s1 | the Ubuntu WSL distro | 50 | runtimeClassName nvidia (k3s creates it when the toolkit is present) | NVIDIA device plugin + runtimeClassName patch on the DaemonSet | yes: any pod with runtimeClassName nvidia | 3 valid cycles of 4 |
| k3d | k3d v5.9.0 | Docker container | none (exit 127) | -v /usr/lib/wsl/lib and /usr/lib/wsl/drivers on the node + hostPath pods + plugin patched with the same mounts | no | 3 of 3 cycles | |
| kind | kind v0.33.0 | Docker container | none (exit 127) | extraMounts for the two WSL folders + hostPath pods + plugin patched with the same mounts | no | 3 of 3 cycles | |
| minikube | minikube v1.39.0 | Docker container | 10 (nvml_init: Not Supported) with --gpus=all | documented --container-runtime=docker --gpus=all | --mount --mount-string=/usr/lib/wsl:/usr/lib/wsl on top of --gpus=all | yes: any image with NVIDIA_VISIBLE_DEVICES=all (nvidia is the default runtime) | 3 of 3 cycles |
| rancher-desktop | Rancher Desktop 1.24.0 | its own WSL distro | 50 | hostPath pod (node has the WSL folders) | hostPath pods + plugin patched with the same mounts | no | 1 cycle |
| docker-desktop-kind | Docker Desktop 4.88.1 | hidden Docker container | none (exit 127) | driver files copied into each pod from an image (tied to driver 621.01) + plugin the same way | no | 1 warm cycle | |
| docker-desktop-kubeadm | Docker Desktop 4.88.1 | Docker Desktop's VM (cri-dockerd) | 50 | hostPath pod (node has the WSL folders) | hostPath pods + plugin patched with the same mounts (RuntimeClass rejected by cri-dockerd) | no | no cycles |
Stock and tuned, with the route for each.
Every one of them reaches a verified GEMM in the end, and every one can have the scheduler ration the card. What differs is how they get there, and there are two routes.
The runtime route. The NVIDIA runtime on the node injects everything. A pod with nvidia.com/gpu: 1 and the RuntimeClass gets the card, unprivileged.
The catch: a pod that names the RuntimeClass but never asks for the GPU gets it too, and the scheduler thinks the card is free.
The mount route. The WSL folders go into the node, then into each GPU pod as hostPath volumes, and the device plugin gets the same mounts so it can count the card.
The catch: every GPU pod is privileged, and one that asks for the GPU but forgets the mounts is scheduled with nothing in it.
Both routes reach level 50 with the GPU rationed. Only k3s and minikube keep GPU pods unprivileged.
The runtime route: k3s and minikube. The NVIDIA runtime injects everything, and pods stay unprivileged. Stock k3sk3s A small Kubernetes distribution that ships as one binary. Mine runs inside a WSL2 distro as the gpu-lab cluster. Glossary finds the toolkit in the distro, adds an nvidia runtime to its containerdcontainerd The container runtime k3s runs pods with. I import images into it directly with k3s ctr images import, so there's no registry in the loop. Glossary and creates an nvidia RuntimeClassRuntimeClass A Kubernetes object that picks which runtime handler starts a pod's containers. The nvidia class adds the GPU libraries; without it a GPU pod can schedule, report Running and still find no CUDA device. Glossary, all without a flag from me, so a pod that names the RuntimeClass reaches level 50 on a fresh install. minikube’s documented path, --gpus=all, stopped at level 10 with Not Supported, the same failure I had hit before. It isn’t a limit in NVML. --gpus gave the node /dev/dxg and some driver-store files but no /usr/lib/wsl/lib, and the toolkit inside the node can only pass on what it was given. One more flag, --mount-string=/usr/lib/wsl:/usr/lib/wsl, and minikube reaches level 50 with unprivileged pods.
The catch on this route is that rationing is opt-in. On k3s, any pod that names the RuntimeClass gets the GPU whether or not it asked for nvidia.com/gpu. On minikube, where nvidia is the node’s default runtime, any image that sets NVIDIA_VISIBLE_DEVICES=all gets it, and every nvidia/cuda image does.
The mount route: k3d, kind, Rancher Desktop, and Docker Desktop in kubeadm mode. The device and the two directories go into the node, then into each pod as hostPath volumes, and the device plugindevice plugin A pod on each node that tells the kubelet how many of a device it has. NVIDIA's advertises GPUs as nvidia.com/gpu, so the scheduler can hand them out like CPU or memory. Glossary gets the same mounts so it can count the card. Nothing reaches the GPU without mounting the paths itself, so rationing holds. The catch is that every GPU pod is privileged, and a pod that asks for the GPU but forgets the mounts gets scheduled with nothing in it.
Docker Desktop in kind mode is the odd one out. Its node is a hidden container I can’t add mounts to, so the only way through was to copy the driver files into every pod from an image, which ties the image to driver 621.01. It works, but I wouldn’t run it.
On both routes the device plugin needed the same fix. As published, it sat at Running with no restarts and never registered a GPU, because the plugin pod itself couldn’t see the card. Giving its DaemonSet runtimeClassName: nvidia (or the mounts) was all it took.
To find the one that fits what you need, try the lab’s which cluster tool.
7. Cost
From nothing installed to a verified GEMM, at one eighth speed. k3s gets there in 16.7 to 19.2 s.
The clusters whose nodes are containers pull an image and start a node first: k3d about a minute, kind 71 to 80 s. Rancher Desktop took 66 s, on Kubernetes 1.25.
minikube takes nearly two minutes. Docker Desktop in kind mode was timed warm, because it would not let me remove its images.
Docker Desktop in kubeadm mode was never timed as a cycle. k3s is about three times faster than anything else.
| Candidate | To Ready (s) | To level 50 (s) | Cycles | RAM (MiB) |
|---|---|---|---|---|
| k3s | 7.9-9.4 | 16.7-19.2 | 3 | 364-382 |
| k3d | 28.6-28.9 | 54.3-63.6 | 3 | 641-667 |
| kind | 45.8-55.9 | 71.2-80.1 | 3 | 599-628 |
| minikube | 85.7-95.4 | 107.2-116.4 | 3 | 617-633 |
| rancher-desktop | 42.8 | 65.9 | 1 | about 590 |
| docker-desktop-kind | 82 | 80.9 | 1 warm | not clean |
| docker-desktop-kubeadm | 69 | not timed as a cycle | 0 | about 700 |
Cold is from nothing installed. RAM is what the cluster added to WSL at idle. Ranges are the fastest and slowest of the timed cycles.
the full table: disk, teardown, and what each leaves behind
| Candidate | Cold to Ready (s) | Cold to level 50 (s) | WSL RAM added (MiB) | Disk (MB) | Teardown | Left behind | Notes |
|---|---|---|---|---|---|---|---|
| k3s | 7.9-9.4 | 16.7-19.2 | 364-382 | 695-739 (/var/lib/rancher) | 3.0-4.4 | /etc/rancher/node/password | dies with the WSL distro when no wsl.exe session is attached |
| k3d | 28.6-28.9 | 54.3-63.6 | 641-667 | 478 images + plugin image in the node | 2.1-2.2 | nothing (kubectl writes ~/.kube/cache) | |
| kind | 45.8-55.9 | 71.2-80.1 | 599-628 | 1340 node image + plugin image | 1.2-1.3 | the kind Docker network | |
| minikube | 85.7-95.4 | 107.2-116.4 | 617-633 | 508 kicbase + Kubernetes preload | 12.9-13.0 | kicbase images; ~/.minikube is recreated by any minikube command | |
| rancher-desktop | 42.8 | 65.9 | about 590 | 6900 (2200 app + 4700 data) | factory reset then 3.1 s uninstall | nothing if factory reset runs first; step 00 found 1.2 GB and two distros left by an uninstall alone | ignores --kubernetes.version on a fresh start |
| docker-desktop-kind | 82 (restart to node Ready) | 80.9 (warm: images could not be removed) | not clean (Docker Desktop restarts change its own footprint) | about 2200 images | manual | containers keep running hidden after Kubernetes is disabled; their volumes; the kind network | |
| docker-desktop-kubeadm | 69 | not timed as a cycle | about 700 (approximate) | about 730 images | manual | exited k8s_ containers hidden after disable |
Everything measured about each candidate's footprint, with the notes as written.
k3s gets to a working GPU pod about three times faster than anything else, 17 to 19 seconds from nothing, and adds about 370 MiB of RAM. The container-node clusters each add 600 to 670 MiB, and minikube takes nearly two minutes. Rancher Desktop costs 6.9 GB of disk, most of it its own data. None of them holds any VRAM.
k3s, k3d, kind and minikube each got three timed cycles, and they agreed. Rancher Desktop and Docker Desktop got one cycle each, and Docker Desktop’s was warm because it wouldn’t let me remove its images.
8. Errors
Here is every distinct error the comparison hit, word for word, in the hope you can skip the detours they cost me:
the table: ten errors, and the message that means it works
| Error | Seen in step | Means |
|---|---|---|
| error while loading shared libraries: libnvidia-ml.so.1: cannot open shared object file (exit 127) | 02 L1none L2none L2m-gpus L2md-gpus; 04, 05, 08 stock; 03 GPU request without the RuntimeClass | nothing delivered /usr/lib/wsl/lib to the container |
| nvml_init: Unable to load the NVML library (level 10) | 02 L1m, L2m-mounts | /usr/lib/wsl/lib without /usr/lib/wsl/drivers, the driver store its libraries load from |
| nvml_init: Not Supported (level 10); plugin: Failed to initialize NVML: Not Supported | 06 with --gpus=all | a runtime injected the driver-store files but not /usr/lib/wsl/lib |
| could not select device driver "" with capabilities: [[gpu]] | 02 L2 | a Docker daemon with no NVIDIA runtime (dind) was asked for --gpus |
| no runtime for "nvidia" is configured | 04 | a RuntimeClass whose handler the node's containerd does not have |
| RuntimeHandler "nvidia" not supported | 08b | cri-dockerd does not pass RuntimeClass handlers through |
| RuntimeClass "nvidia" not found | 07, 08b | no RuntimeClass exists |
| Insufficient nvidia.com/gpu | 03 to 08b | no device plugin registered the GPU, or the one GPU is taken |
| hostPath type check failed: /usr/lib/wsl/lib is not a directory | 04, 05, 06, 08 | the node container was not given the WSL folders |
| Incompatible strategy detected auto ... invalid device discovery strategy | 03 | the device plugin pod cannot see the GPU: its DaemonSet lacks runtimeClassName: nvidia |
| Detected platform: wsl ... Registered device plugin for 'nvidia.com/gpu' | 03 to 08b | healthy device plugin |
Each message as it was printed, where I saw it, and what it means. Steps are numbered as in section 1; L1 and L2 are rungs of the Docker ladder.
Most of them point one layer away from the real problem. “Cannot open shared object file” isn’t a missing library in your image; it’s a directory that never reached the container. “Insufficient nvidia.com/gpu” is often the right answer: the one GPU is taken. Paste any of them into the lab’s error decoder for the layer and the fix, or walk the stack from the Windows driver up with layer triage.
9. Side effects
None of these are GPU results, but each one cost me time:
- WSL stops a distro about a minute after its last
wsl.exesession closes, and a k3s cluster in it dies with it. Docker Desktop and Rancher Desktop keep their own distros alive. - Docker Desktop’s Resource Saver restarts its engine, and
restart: alwaysthen brings back containers you stopped by hand. - Docker Desktop hides its Kubernetes containers from
docker ps -a, and in kind mode it leaves the node running after you disable Kubernetes. Its settings file has to be edited while it’s stopped, or it writes its old value back. - Rancher Desktop starts Kubernetes 1.25.16 unless you set a version on a running instance, and uninstalling it without a factory reset first leaves 1.2 GB and two distros behind.
- dind and Docker Desktop’s hidden containers leak anonymous volumes unless they’re removed with
-v. - Any minikube command recreates
~/.minikube, evenminikube version, and kubectl on Windows writes~/.kube/cachewhateverKUBECONFIGsays. - k3d’s Windows build can’t parse
-v ...:ro.
10. Verdict
k3s. Against the requirements in section 1 it is the fastest from nothing, the lightest, and along with minikube the only option where GPU pods run unprivileged. minikube is the runner-up on the same route, but it is six times slower to start and its rationing hole is wider. The mount-route options all work, but every GPU pod on them has to be privileged, which fails the third requirement.
k3s has two catches, and both matter here:
- It dies with its distro. WSL stops the Ubuntu distro a minute after the last terminal closes, and the cluster goes with it.
- Rationing is opt-in. A pod that names the RuntimeClass without requesting
nvidia.com/gpugets the card anyway, and the scheduler thinks it’s free. The VRAM harness I’m building next (#10) decides whether it has the card to itself by readingnvidia.com/gpuallocations, so a pod that goes around them is invisible to it.
Fixing both, and turning k3s into a cluster I can leave running and drive with one command, is the next post. The full record of this one, every command with what it printed, is in the notebook, and the scripts and the probe are in bench/cluster-matrix/.
If your numbers disagree with mine, I want to hear it.
11. Sources
- NVIDIA: CUDA on WSL user guide
- NVIDIA Container Toolkit
- NVIDIA k8s-device-plugin
- k3s: NVIDIA container runtime support
- Kubernetes: RuntimeClass
- minikube: using NVIDIA GPUs
- kind: extra mounts
- Microsoft: WSL configuration and idle timeout
Changelog
- 2026-11-11new labGPU cluster lab
- 2026-11-11Published.