1 × RTX 5060 · 8 GB · Blackwell sm_120 · CUDA 13.4 · Ryzen 5 8400F4 posts · 0 errata · last measurement 2026-11-16
Kokou
← Posts

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.

2026-11-1110 mincost: $0 · one machine, one dayrepochangelog
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: true if 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.

A pod at 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-smi working 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:

StepWhenMedianIQRSpread
01 instrumentlive226501
02 Docker ladderlive2284210
03 k3spre-install232723
04 k3dpre-install2323839
05 kindpre-install226312
06 minikubepre-install219022
07 Rancher Desktoppre-install233612
08 Docker Desktoppre-enable223733

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
WINDOWS DRIVER/dev/dxg/usr/lib/wsl/lib/usr/lib/wsl/driversCONTAINER ON WSL2/dev/dxg/usr/lib/wsl/lib/usr/lib/wsl/driversput there by the runtime, or by handput there by the runtime, or by handPROBEexit 127 · libnvidia-ml.so.1: cannot open shared object filelevel 10 · nvml_init: Unable to load the NVML librarylevel 50 · a GEMM ran and every element checked out

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.

--GPUS ALLDEVICE + 2 FOLDERSL1 · docker run --gpus allL2 · dind, then --gpus allL1 · --device, two -vL2 · dind, same flags againlevel 50could not select devicedriver "" with [[gpu]]mounts inside: exit 127outer got files, not folderslevel 50, no toolkitlevel 50the GPU survives nesting · --gpus does not

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.

RungOuter containerInner containerLevelError
L1nonedocker run (NVIDIA_VISIBLE_DEVICES=void)nonelibnvidia-ml.so.1: cannot open shared object file (exit 127)
L1docker run --gpus all50
L1mdocker run --device /dev/dxg + /usr/lib/wsl/lib + LD_LIBRARY_PATH10nvml_init: Unable to load the NVML library
L1mdL1m + /usr/lib/wsl/drivers50
L2nonedocker:28-dind --privileged --gpus alldocker runnonelibnvidia-ml.so.1: cannot open shared object file (exit 127)
L2docker:28-dind --privileged --gpus alldocker run --gpus allnonecould not select device driver "" with capabilities: [[gpu]]
L2m-gpusdocker:28-dind --privileged --gpus allL1m's flagsnonelibnvidia-ml.so.1: cannot open shared object file (exit 127)
L2m-mountsdocker:28-dind --privileged + /dev/dxg + /usr/lib/wsl/libL1m's flags10nvml_init: Unable to load the NVML library
L2md-gpusdocker:28-dind --privileged --gpus allL1md's flagsnonelibnvidia-ml.so.1: cannot open shared object file (exit 127)
L2md-mountsdocker:28-dind --privileged + /dev/dxg + lib + driversL1md's flags50

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

CandidateStockTunedRationedPrivileged podsUnasked pod gets GPU
plain Docker (control)5050n/anon/a
k3s5050yesnoyes
k3dnone50yesyesno
kindnone50yesyesno
minikube1050yesnoyes
rancher-desktop5050yesyesno
docker-desktop-kindnone50yesyesno
docker-desktop-kubeadm5050yesyesno

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
CandidateVersionThe node isStock levelStock, howTuned routeA pod that never asks for the GPURepeats
plain Docker (control)Docker Desktop 4.88.1container (control)50--gpus alldevice + /usr/lib/wsl/lib + /usr/lib/wsl/drivers + LD_LIBRARY_PATH (no toolkit)n/a3 of 3 runs identical
k3sk3s v1.36.5+k3s1the Ubuntu WSL distro50runtimeClassName nvidia (k3s creates it when the toolkit is present)NVIDIA device plugin + runtimeClassName patch on the DaemonSetyes: any pod with runtimeClassName nvidia3 valid cycles of 4
k3dk3d v5.9.0Docker containernone (exit 127)-v /usr/lib/wsl/lib and /usr/lib/wsl/drivers on the node + hostPath pods + plugin patched with the same mountsno3 of 3 cycles
kindkind v0.33.0Docker containernone (exit 127)extraMounts for the two WSL folders + hostPath pods + plugin patched with the same mountsno3 of 3 cycles
minikubeminikube v1.39.0Docker container10 (nvml_init: Not Supported) with --gpus=alldocumented --container-runtime=docker --gpus=all--mount --mount-string=/usr/lib/wsl:/usr/lib/wsl on top of --gpus=allyes: any image with NVIDIA_VISIBLE_DEVICES=all (nvidia is the default runtime)3 of 3 cycles
rancher-desktopRancher Desktop 1.24.0its own WSL distro50hostPath pod (node has the WSL folders)hostPath pods + plugin patched with the same mountsno1 cycle
docker-desktop-kindDocker Desktop 4.88.1hidden Docker containernone (exit 127)driver files copied into each pod from an image (tied to driver 621.01) + plugin the same wayno1 warm cycle
docker-desktop-kubeadmDocker Desktop 4.88.1Docker Desktop's VM (cri-dockerd)50hostPath pod (node has the WSL folders)hostPath pods + plugin patched with the same mounts (RuntimeClass rejected by cri-dockerd)nono 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.

RUNTIME · k3s, minikubeNODE · NVIDIA RUNTIMEinjects everythingPOD Aasks gpu: 1POD Bnever asksGPU, unprivilegedGPU anywaycounted as freeMOUNTS · k3d, kind, Rancher, DDNODE · WSL FOLDERS MOUNTEDhostPath into each podPOD Agpu: 1, mountsPOD Bgpu: 1 onlyGPU, privilegedscheduled,no GPU in itboth reach level 50 with the GPU rationed

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, SECONDS0306090120 sk3s16.7 to 19.2 sk3d54.3 to 63.6 srancher-desktop65.9 skind71.2 to 80.1 sdocker-desktop-kind80.9 s, warmminikube107.2 to 116.4 sdocker-desktop-kubeadmnot timed as a cycle
k3sthe others, fastest cycletimed warmnot timed

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.

CandidateTo Ready (s)To level 50 (s)CyclesRAM (MiB)
k3s7.9-9.416.7-19.23364-382
k3d28.6-28.954.3-63.63641-667
kind45.8-55.971.2-80.13599-628
minikube85.7-95.4107.2-116.43617-633
rancher-desktop42.865.91about 590
docker-desktop-kind8280.91 warmnot clean
docker-desktop-kubeadm69not timed as a cycle0about 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
CandidateCold to Ready (s)Cold to level 50 (s)WSL RAM added (MiB)Disk (MB)TeardownLeft behindNotes
k3s7.9-9.416.7-19.2364-382695-739 (/var/lib/rancher)3.0-4.4/etc/rancher/node/passworddies with the WSL distro when no wsl.exe session is attached
k3d28.6-28.954.3-63.6641-667478 images + plugin image in the node2.1-2.2nothing (kubectl writes ~/.kube/cache)
kind45.8-55.971.2-80.1599-6281340 node image + plugin image1.2-1.3the kind Docker network
minikube85.7-95.4107.2-116.4617-633508 kicbase + Kubernetes preload12.9-13.0kicbase images; ~/.minikube is recreated by any minikube command
rancher-desktop42.865.9about 5906900 (2200 app + 4700 data)factory reset then 3.1 s uninstallnothing if factory reset runs first; step 00 found 1.2 GB and two distros left by an uninstall aloneignores --kubernetes.version on a fresh start
docker-desktop-kind82 (restart to node Ready)80.9 (warm: images could not be removed)not clean (Docker Desktop restarts change its own footprint)about 2200 imagesmanualcontainers keep running hidden after Kubernetes is disabled; their volumes; the kind network
docker-desktop-kubeadm69not timed as a cycleabout 700 (approximate)about 730 imagesmanualexited 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
ErrorSeen in stepMeans
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 RuntimeClassnothing 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 Supported06 with --gpus=alla runtime injected the driver-store files but not /usr/lib/wsl/lib
could not select device driver "" with capabilities: [[gpu]]02 L2a Docker daemon with no NVIDIA runtime (dind) was asked for --gpus
no runtime for "nvidia" is configured04a RuntimeClass whose handler the node's containerd does not have
RuntimeHandler "nvidia" not supported08bcri-dockerd does not pass RuntimeClass handlers through
RuntimeClass "nvidia" not found07, 08bno RuntimeClass exists
Insufficient nvidia.com/gpu03 to 08bno device plugin registered the GPU, or the one GPU is taken
hostPath type check failed: /usr/lib/wsl/lib is not a directory04, 05, 06, 08the node container was not given the WSL folders
Incompatible strategy detected auto ... invalid device discovery strategy03the device plugin pod cannot see the GPU: its DaemonSet lacks runtimeClassName: nvidia
Detected platform: wsl ... Registered device plugin for 'nvidia.com/gpu'03 to 08bhealthy 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.exe session 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: always then 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, even minikube version, and kubectl on Windows writes ~/.kube/cache whatever KUBECONFIG says.
  • 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:

  1. It dies with its distro. WSL stops the Ubuntu distro a minute after the last terminal closes, and the cluster goes with it.
  2. Rationing is opt-in. A pod that names the RuntimeClass without requesting nvidia.com/gpu gets 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 reading nvidia.com/gpu allocations, 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

Changelog