Commit 9a8181d
committed
ollama: WSL2 CDI fallback + AddDevice so the dev VM uses the NVIDIA GPU
Operator-flagged 2026-05-11: ollama in podman-MiOS-DEV loaded models
on CPU (`load_tensors: CPU model buffer size = 16676 MiB`) despite
nvidia-smi inside the dev VM working fine (`NVIDIA GeForce RTX 4090
... CUDA Version: 13.1`). Root causes:
1. mios-cdi-detect.service detected WSL2 + NVIDIA but bailed because
nvidia-ctk isn't installed on podman-machine-os 6.0 (the dev VM
base) and can't be cleanly layered. /etc/cdi/ stayed empty, so
podman had no nvidia.com/gpu=all spec to attach.
2. usr/share/containers/systemd/ollama.container had no AddDevice=
for the GPU. Even if a CDI spec existed, the container started
without the device class so /dev/dxg + /usr/lib/wsl never made
it inside.
Fixes:
mios-cdi-detect -- when HAS_NVIDIA && (VIRT=wsl || /dev/dxg) but
nvidia-ctk is missing, hand-roll /run/cdi/wsl2-nvidia.yaml with:
* deviceNodes: /dev/dxg
* mounts: /usr/lib/wsl rbind ro nosuid nodev
(rbind is critical -- /usr/lib/wsl/lib is an overlay sub-mount
on the WSL2 host that doesn't propagate through a plain bind,
so the container would see an empty /usr/lib/wsl/lib/ otherwise)
* env: LD_LIBRARY_PATH=/usr/lib/wsl/lib:/usr/local/nvidia/lib:...
ollama.container -- add AddDevice=nvidia.com/gpu=all so podman
attaches whichever CDI spec mios-cdi-detect emitted (nvidia.yaml on
bare metal via nvidia-ctk, or wsl2-nvidia.yaml on the dev VM).
AMD/Intel hosts can override via .container.d/ drop-ins.
Verified live on operator's RTX 4090 install:
ollama runner.go: inference compute library=CUDA name=CUDA0
description="NVIDIA GeForce RTX 4090" compute=8.9 driver=13.1
total="24.0 GiB" available="18.7 GiB"1 parent 95471ae commit 9a8181d
2 files changed
Lines changed: 43 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
79 | 111 | | |
80 | 112 | | |
81 | 113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
26 | 37 | | |
27 | 38 | | |
28 | 39 | | |
| |||
0 commit comments