Schedule icon
Webhook icon
Request icon
Script icon
If icon
Log icon
Loop icon
SlackIncomingWebhook icon

Ollama GPU VRAM Saturation and Idle Model Eviction Sentinel

Audit Ollama LLM serving nodes for GPU VRAM exhaustion, CPU RAM spilling bottlenecks, and automate idle model eviction with alerts using Kestra orchestration.

Categories
AIInfrastructure

Running local large language models (LLMs) with Ollama on shared GPU servers or workstations frequently leads to silent memory saturation. When new inference tasks load additional models, existing models remain resident in GPU VRAM until their keep_alive window expires. If cumulative weights exceed physical VRAM capacity, Ollama either fails with CUDA out-of-memory (OOM) errors or silently spills model layers onto system RAM, resulting in orders-of-magnitude slower token generation.

This blueprint provides an autonomous reliability sentinel that periodically inspects Ollama's active model telemetry, calculates physical GPU VRAM saturation ratios, identifies models operating in hybrid CPU/RAM offload mode, and optionally triggers proactive model unloads (keep_alive: 0) to safeguard cluster headroom.

How it works

  1. check_ollama_liveness validates that the Ollama HTTP daemon is responsive by polling the /api/version endpoint.
  2. fetch_running_models extracts model metadata, total size, VRAM footprint (size_vram), and expiration timestamps from /api/ps.
  3. evaluate_vram_and_spilling executes an in-container Python analysis task that compares active allocations against configured physical GPU memory (total_gpu_vram_gb), detects any layer spilling (size_vram < size), and assigns operational health tiers (HEALTHY, WARNING, CRITICAL).
  4. check_and_remediate_idle_models evaluates whether critical saturation was reached and, if auto_evict_idle_models is enabled, iterates through resident models using a Loop flowable task to trigger immediate GPU cache release via /api/generate with keep_alive: 0.
  5. dispatch_slack_alert posts an actionable diagnostic card to Slack whenever thresholds are breached or CPU RAM spilling is detected.
  6. The errors block catches connection or runtime timeouts and notifies Slack.

What you get

  • Automated GPU memory headroom audit without running invasive host monitoring agents.
  • Early detection of CPU RAM layer offloading, which causes severe inference throughput collapse.
  • Configurable threshold-based alerting (WARNING and CRITICAL) with detailed utilization statistics.
  • Automated self-healing eviction workflow to reclaim VRAM without restarting the Ollama daemon.

Who it's for

  • Platform engineers and MLOps teams hosting shared Ollama instances for developers or internal applications.
  • AI engineers serving multiple fine-tuned or multi-size models (e.g., Llama 3, Mistral, Qwen) on limited GPU hardware.
  • DevOps engineers looking to automate GPU cluster hygiene and eliminate manual process restarts.

Why orchestrate this with Kestra

  • Declarative workflows eliminate the need for custom Python cron daemons or fragile bash scripts.
  • Built-in conditional execution (If) and iteration (Loop) manage multi-step remediation safely.
  • Native alerting tasks (SlackIncomingWebhook) dispatch actionable diagnostic payloads directly into team channels without third-party integrations.
  • Centralized execution history provides auditable logs of all model evictions and saturation events.

Prerequisites

  • A running Ollama instance accessible over HTTP (default: http://localhost:11434).
  • Python runtime container execution capability on the Kestra worker (Docker or Process runner).
  • An optional Slack Incoming Webhook URL for alerting.

Secrets

  • SLACK_WEBHOOK_URL: Optional Slack Incoming Webhook URL configured in namespace secrets or passed via inputs.

Quick start

  1. Adjust ollama_endpoint to match your Ollama host (e.g., http://ollama-service.mlops.svc.cluster.local:11434).
  2. Set total_gpu_vram_gb to the physical VRAM size of your GPU (e.g., 24.0 for RTX 3090/4090/A5000, 80.0 for A100/H100).
  3. Configure slack_webhook_url if you want team channel alerts.
  4. Enable auto_evict_idle_models: true if you want Kestra to automatically unload models when memory exceeds vram_critical_threshold_pct.
  5. Enable the schedule trigger or call the webhook trigger ollama-vram-audit from your CI/CD or monitoring system.

How to extend

  • Add Prometheus pushgateway tasks to export VRAM metrics into your Grafana dashboards.
  • Pair with an Ollama model preload task that warms specific high-priority models during off-peak hours.
  • Implement priority-based eviction that only unloads models matching specific name patterns or tags.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.