Unload idle Ollama models and log GPU usage with HTTP and file writes
Ready for 3.0What this workflow does
This workflow has 10 nodes and runs manually, when you click “Execute workflow” (plus 1 other trigger). It uses only n8n's built-in nodes.
How it runs
Trigger: Manually, when you click “Execute workflow” (plus 1 other trigger).
- Settings (Edit Fields (Set)): sets 6 fields: ollamaUrl, dryRun, idleMinutes…
- List loaded models (HTTP Request): calls an HTTP API (GET)
- Decide idle models (Code): runs custom JavaScript code
- Changed since last run? (If): checks a condition and branches into true / false
- Live unload needed? (If): checks a condition and branches into true / false
- Pack log line (Code): runs custom JavaScript code
- Unload model in Ollama (HTTP Request): calls an HTTP API (POST)
- Append guard log (Read/Write Files from Disk): writes a file to disk
Before you upgrade to n8n 3.0
Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.
Nodes used (7)
- Manual Trigger
n8n-nodes-base.manualTrigger - Schedule Trigger
n8n-nodes-base.scheduleTrigger - Edit Fields (Set)
n8n-nodes-base.set - HTTP Request
n8n-nodes-base.httpRequest - Code
n8n-nodes-base.code - If
n8n-nodes-base.if - Read/Write Files from Disk
n8n-nodes-base.readWriteFile
From the author
Quick Overview This workflow runs manually or every 10 minutes to check which Ollama models are loaded, log state changes to a file, and optionally unload models that have been idle too long to free GPU memory. How it works 1. Runs on a manual trigger or on a…