The GPU Freeze That Was Out of Memory: Six Power Cycles and a Billion Open Files

In progress Kubernetes Linux

My homelab's GPU worker is a gaming laptop with a GTX 1070, joined to a bare-metal Kubernetes cluster as a tainted node for media transcoding and local AI. On the day the NVIDIA device plugin went in, the very first smoke test, a pod running nvidia-smi, froze the whole laptop. It took six power cycles to find nothing, then one evening and a different method to find that the GPU had never been the problem: nvidia-smi was eating all 15 GiB of RAM in three seconds, because containerd gives every container a limit of a billion open files.

Impact

  • Actual: six reproductions, each ending with the power button. The node is a worker, etcd lives elsewhere, so no data was lost; a forced power-off left the EFI partition dirty once.
  • Blocked: every GPU workload and the media stack rollout, which requests the GPU, from the device-plugin rollout until the fix, the same evening.
  • Misdiagnosis: for most of the day it was treated as a GPU or driver hang, and the test plan was built around the driver, the container toolkit and the kernel.

Timeline

  • Afternoon - The device plugin is synced by Argo CD, the card is time-sliced into four shares, and a two-pod nvidia-smi smoke test freezes the node: the table header prints, then nothing. Ping answers, SSH times out during the banner, the node goes NotReady.
  • Afternoon - Six reproductions, one change per power cycle. The host runs the same command fine; nvidia-smi -L works from the failing container; the device plugin's own container runs the full command fine. Ruled out: the plugin, time-slicing, persistence mode, capabilities, library versions, timing. Lockup and hung-task panics are armed, and netconsole streams kernel messages to my Mac. Neither reports anything.
  • Evening, first check - A test script now verifies the diagnostics before every test, and finds that netconsole had never delivered a single line: without a target MAC address it sends broadcast frames, which my router doesn't forward to the Mac on Wi-Fi. "No kernel trace" had meant nothing all day.
  • Evening - Real workloads first: a CUDA sample and Jellyfin's ffmpeg (hardware encode and decode at ten times real time) both pass. Then a fresh pod with the device plugin's image runs the full nvidia-smi fine. The image matters.
  • Evening - A diff of the two containers shows MIG capability devices only in the working one; NVML turns out to create them itself. Pre-creating them in the failing image changes one thing: the query hangs as usual, but this time the node survives and the pod comes back OOMKilled, with no memory limit set.
  • Evening - The kernel log: nvidia-smi at 15.4 GB resident, 54 GB virtual, three seconds after it started. In a pod with a 1 GiB memory limit, the persistence-mode query alone gets killed; the same container with ulimit -n 1024 prints the full table.
  • Evening - A containerd drop-in caps the limit; new containers get 1024 / 524288, the original repro and the two-pod smoke test pass. Rolled out to the control plane too.

Root cause

  • containerd 1.7's systemd unit sets LimitNOFILE=infinity, so every container starts with the kernel's maximum: 1073741816 open files.
  • The full nvidia-smi table includes persistence mode, which NVML gets from nvidia-persistenced over a socket. That path allocates by the open-files limit: about 54 GB here. NVIDIA has acknowledged the bug in nvidia-persistenced and suggests a lower hard limit until a fixed driver ships; a Debian bug report shows the same two huge maps right after the limit is read.
  • nvidia-smi -L doesn't ask for persistence mode, and the device plugin's minimal image never took that path, which is why both worked.
  • The node has 15 GiB and no swap. The OOM killer usually lost the race against thrashing: the kernel stayed alive (ping), user space starved (SSH, kubelet), and with nothing stuck in the kernel, there was nothing to log. It looked exactly like a hardware hang.

Actions

  • Fix: LimitNOFILE=1024:524288 in a containerd systemd drop-in, written by the containerd playbook with an assertion on the running service. Applied to both nodes; containerd's KillMode=process kept running pods alive through the restart.
  • Verified: a new container shows soft 1024 / hard 524288; the original failing pod and the two-pod time-sliced test print the full table.
  • Test kit kept: a script that checks netconsole actually arrives before each test, runs every GPU step under a watchdog that force-deletes the pod when the node stops answering, and pods for each hypothesis, including a memory-limited one.
  • Next: memory limits on every GPU workload; consider swap or eviction thresholds on the GPU node; upgrade to containerd 2.x, which no longer sets the limit.

Lessons learned

  • A diagnostic that reports nothing must be tested before its silence counts as evidence. One marker line through /dev/kmsg would have shown netconsole was broken on the first day.
  • Name the symptom, not the cause. "GPU freeze" came from where the output stopped. "The node stops answering SSH but answers ping" points at memory pressure as much as at hardware.
  • Limit what you test. A memory limit on the first test pod would have turned a frozen node into an OOMKilled pod in seconds, and the kernel log would have named the culprit.
  • Test real workloads first. CUDA and hardware encoding worked all along; knowing that early unblocked the media stack and narrowed the problem to one query.
  • When each test costs a reboot, do the free comparisons first. Diffing two containers and reading the log after a non-fatal run found more than six power cycles did.

References