Skip to Content
GPU OptimizationGPU Out-of-Memory Detection

GPU Out-of-Memory Detection
Available in v1.34.14+

ScaleOps uses a Kubernetes mutating admission webhook to inject a GPU out-of-memory detection library into GPU pods at creation time. This gives per-pod and per-workload GPU out-of-memory visibility without any code changes or manual configuration in your workloads.

ℹ️

GPU out-of-memory detection is a Beta feature and is off by default. See Enabling GPU Out-of-Memory Detection.

This feature is detection-only. It reports out-of-memory events and never changes GPU requests, resizes workloads, or applies a recommendation of its own.

How It Works

A GPU out-of-memory event is a failed GPU memory allocation. Unlike regular OOM, it leaves no Kubernetes trace: no OOMKilled status, no kernel event, no DCGM metric. ScaleOps closes that gap by detecting these events inside the GPU process and surfacing them in the dashboard.

When GPU out-of-memory detection is enabled (via GPU policy), the ScaleOps admission controller intercepts pod creation events and injects the detection components.

Step-by-step:

  1. Enablement - A user enables GPU out-of-memory detection via the GPU policy (UI or GitOps).
  2. Pod creation - A new GPU pod is created.
  3. Webhook mutates pod spec - The ScaleOps admission webhook patches the pod spec: adds an init container, a metrics sidecar (native sidecar on Kubernetes 1.29+), two emptyDir volumes, and the LD_PRELOAD environment variable on the GPU container.
  4. Init container - Injects the detection library via LD_PRELOAD, giving visibility into CUDA allocation failures.
  5. Sidecar - Collects the detected events from the library and exposes them as metrics.
  6. Collection - ScaleOps Prometheus scrapes the sidecar.
⚠️

If your container image already relies on LD_PRELOAD, make sure it is defined in the pod spec (Deployment/StatefulSet manifest), not baked into the image. When LD_PRELOAD is set in the pod spec, ScaleOps prepends its path (colon-separated) to preserve your existing value. If it is only set inside the image (e.g. via ENV in the Dockerfile), ScaleOps will override it. If it is sourced from a ConfigMap or Secret via valueFrom, ScaleOps cannot merge it and skips injection for that workload.

What Gets Added to Your Pods

The webhook modifies the pod spec at admission time. No changes are made to your Deployment or StatefulSet manifests - the mutation happens only on the pod object. Only the container that ScaleOps identified as the workload’s GPU container is instrumented.

Below is a simplified view of the fields the webhook adds to a pod:

metadata: labels: scaleops.com/gpu-oom-detection-injected: "true" # marks the pod as instrumented scaleops.com/gpu-metrics: "true" # service discovery label spec: initContainers: - name: scaleops-gpu-oom-init # runs before app containers image: registry.scaleops.com/scaleops-injectors:<tag> command: ["sh", "-c"] args: ["cp -r /opt/scaleops/gpu-oom/. /scaleops-libs/gpu-oom/"] volumeMounts: - name: scaleops-gpu-oom mountPath: /scaleops-libs/gpu-oom/ containers: - name: my-gpu-app # your GPU container env: - name: LD_PRELOAD value: /scaleops-libs/gpu-oom/preload.so - name: SCALEOPS_DATA_DIR value: /scaleops-data/ volumeMounts: - name: scaleops-gpu-oom mountPath: /scaleops-libs/gpu-oom/ readOnly: true - name: scaleops-gpu-data mountPath: /scaleops-data/ - name: scaleops-gpu-oom-sidecar # metrics sidecar image: registry.scaleops.com/scaleops-injectors:<tag> command: ["/opt/scaleops/gpu-oom/sidecar"] ports: - name: gpu-metrics containerPort: 21513 volumeMounts: - name: scaleops-gpu-data mountPath: /scaleops-data/ readOnly: true volumes: - name: scaleops-gpu-oom emptyDir: {} - name: scaleops-gpu-data emptyDir: medium: Memory # RAM-backed; counts against pod memory

If port 21513 is already taken in the pod, ScaleOps resolves the next available port automatically.

On Kubernetes 1.29 and later, the metrics sidecar is deployed as a native sidecar (an init container with restartPolicy: Always) instead of a regular container.

Prerequisites

ScaleOps GPU Optimization installation.

Enabling GPU Out-of-Memory Detection

Detection is controlled by the workload’s GPU policy. Every built-in policy ships with detection off, so no cluster starts instrumenting pods without opting in.

Via UI

Navigate to GPU Rightsizing → Policies, then create or edit a policy. The GPU out-of-memory detection section offers two switches:

  • Enable for all workloads using this policy: instruments every workload assigned this policy.
  • Enable only for automated workloads using this policy: instruments only workloads whose GPU automation is enabled.

Enable for all workloads takes precedence: when it is on, the automation-only switch has no additional effect.


GPU out-of-memory detection section in the GPU policy dialog

Via GitOps

Set the fields on the GpuPolicy resource:

apiVersion: analysis.scaleops.sh/v1alpha1 kind: GpuPolicy metadata: name: my-gpu-policy namespace: scaleops-system spec: gpuOomDetection: enable: true enableOnlyWithAutomation: false
FieldTypeDefaultDescription
gpuOomDetection.enablebooleanfalseEnable detection for all workloads using this policy
gpuOomDetection.enableOnlyWithAutomationbooleanfalseEnable detection only for workloads using this policy whose GPU automation is enabled

Instrumentation is applied at pod creation, so existing pods are instrumented on their next rollout. Turning detection off never triggers a rollout; pods shed the injection naturally as they churn.

Detection Healing

Because detection loads a library into your GPU process, ScaleOps monitors every instrumented pod and backs out automatically if the injection is implicated in a failure.

What the healing mechanism detects

  • Failure of the ScaleOps init container
  • The GPU container crash-looping after the shim was loaded
  • The metrics sidecar crash-looping
  • Probe failures during startup (liveness, readiness, or startup probes)
  • Excessive container restarts
  • The ScaleOps Prometheus failing to scrape the pod’s metrics port

What happens on failure

The affected pods are evicted so the injection is removed, and instrumentation is suspended for the workload. Unlike Java observability, a first failure is never treated as fatal. It is always a temporary failure with a retry window, after which ScaleOps attempts instrumentation again. A failure that recurs after the retry window has already elapsed disables instrumentation for the workload permanently.

ℹ️

If GPU out-of-memory events were actually detected on the workload, the healing mechanism keeps instrumentation running instead of disabling it. An out-of-memory event is itself a common cause of the crash that would otherwise look like an injection failure, so ScaleOps does not disable the very mechanism that is explaining the crash.

Dashboard

Workload Diagnostics Timeline

Detected events appear on the workload’s diagnostics timeline as GPU Out-of-Memory markers.


GPU Out-of-Memory event on the workload diagnostics timeline

Troubleshooting Charts

Two charts are available in the GPU chart category on a workload’s Troubleshoot tab:

  • GPU Out-of-Memory Events: out-of-memory events over time, with a series per CUDA call that reported out-of-memory (cudaMalloc, cudaMallocAsync, and so on), so you can see which call ran out of memory
  • GPU Memory During Out-of-Memory Event: used and free device memory at the moment of each event

GPU Out-of-Memory Events chart
GPU Memory During Out-of-Memory Event chart

GPU Out-of-Memory Events is also available cluster-wide in the GPU category of the Troubleshooting page, for finding which workloads are hitting GPU memory limits across the cluster.

Limitations

Used and free memory are device-wide. In GPU Memory During Out-of-Memory Event, Used and Free refer to the entire GPU device at the moment of the event, not only this workload’s share of it. On a shared GPU, another workload’s allocation is included in Used.

Helm Reference

For the injector Helm values, see the Helm Configuration Reference - injectors. These values control the shape of the injection (container names, port, network policy); enablement itself is driven by the GPU policy, not by Helm.