{"id":50683050,"url":"https://github.com/wlanboy/vram-model-calculator","last_synced_at":"2026-06-08T20:30:45.827Z","repository":{"id":355069897,"uuid":"1226649731","full_name":"wlanboy/vram-model-calculator","owner":"wlanboy","description":"Python based calculator for total vram usage of you gguf models","archived":false,"fork":false,"pushed_at":"2026-06-07T16:12:47.000Z","size":204,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-07T16:16:21.828Z","etag":null,"topics":["calculator","context","mirror","model-fitting","python","vram"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wlanboy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-01T17:04:36.000Z","updated_at":"2026-06-07T16:12:50.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/wlanboy/vram-model-calculator","commit_stats":null,"previous_names":["wlanboy/vram-model-calculator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wlanboy/vram-model-calculator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlanboy%2Fvram-model-calculator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlanboy%2Fvram-model-calculator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlanboy%2Fvram-model-calculator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlanboy%2Fvram-model-calculator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wlanboy","download_url":"https://codeload.github.com/wlanboy/vram-model-calculator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlanboy%2Fvram-model-calculator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34080025,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["calculator","context","mirror","model-fitting","python","vram"],"created_at":"2026-06-08T20:30:43.605Z","updated_at":"2026-06-08T20:30:45.804Z","avatar_url":"https://github.com/wlanboy.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# VRAM Model Calculator\n\nBeantwortet eine einfache Frage: **Passt dieses GGUF-Modell in meine GPU?**\n\nDas Tool scannt lokale GGUF-Dateien, liest deren Metadaten aus und berechnet den VRAM-Bedarf für verschiedene Kontextlängen — vom kurzen Chat-Einsatz bis hin zu langen Coding-Agent-Läufen. Das Ergebnis lässt sich sowohl im Terminal als auch als interaktive Webseite anzeigen.\n\nhttps://wlanboy.github.io/vram-model-calculator/\n\n---\n\n## Tutorial: von Null zum Ergebnis\n\n### 1. Voraussetzungen\n\nPython 3.11+ und `uv` (empfohlen) oder `pip`.\n\n**Option A — Als installiertes CLI-Tool (empfohlen):**\n\n```bash\nuv build\nuv tool install dist/vram_model_calculator-0.1.0-py3-none-any.whl\n```\n\n**Option B — Direkt aus dem Repo:**\n\n```bash\n# Mit uv\nuv sync\n\n# Oder klassisch\npip install gguf tqdm\n```\n\n### 2. GGUF-Modelle scannen\n\nZeige auf das Verzeichnis, in dem deine `.gguf`-Dateien liegen (LM Studio legt sie z. B. unter `~/LMStudio/models/` ab):\n\n```bash\n# Als installiertes Tool (Option A)\ngguf-scanner ~/LMStudio/models/\n\n# Direkt aus dem Repo (Option B)\nuv run -m vram_model_calculator.gguf_scanner ~/LMStudio/models/\nuv run -m vram_model_calculator.gguf_scanner ~/.lmstudio/models/\n```\n\nDer Scanner liest die Metadaten aus jeder GGUF-Datei (Architektur, Layer-Anzahl, Embedding-Dimension, Quantisierung usw.) und speichert alles in `models_cache.json`. Bereits gescannte Dateien werden beim nächsten Aufruf übersprungen — nur neue oder geänderte Dateien werden verarbeitet.\n\n```\n🔍 5 Modelle werden analysiert...\nGGUF Scan: 100%|████████████| 5/5 [00:03\u003c00:00]\n💾 Cache gespeichert unter 'models_cache.json' (28 Einträge).\n```\n\n### 3. VRAM-Matrix im Terminal anzeigen (optional)\n\n```bash\n# Als installiertes Tool (Option A)\nvram-calculator\n\n# Direkt aus dem Repo (Option B)\nuv run -m vram_model_calculator.vram_calculator\n```\n\nGibt für jedes Modell eine Tabelle aus, die zeigt, wie viel VRAM für jeden Anwendungsfall benötigt wird und ob es in die konfigurierten GPUs passt:\n\n```\n🤖 Qwen3-4B-Thinking-2507-Q4_K_M\nArch: qwen3 | Size: 2.33 GB\nUsecase      | KV-Cache   | 6GB (Entry) | 12GB (Mid) | 16GB (Pro) | 24GB (Ultra)\nChat (8k)    |     0.19GB | 🟢  2.5G   | 🟢  2.5G  | ...\nAgent (512k) |    11.87GB | 🔴 14.2G   | 🟡 14.2G  | ...\n```\n\n### 4. Interaktive Webansicht öffnen\n\n```bash\npython -m http.server\n```\n\nDann im Browser: [http://localhost:8000](http://localhost:8000)\n\nDie Seite lädt `models_cache.json` direkt, berechnet alle VRAM-Werte im Browser und zeigt eine filterbare Tabelle.\n\n\u003e `fetch()` benötigt einen HTTP-Server — direktes Öffnen der `index.html` per `file://` funktioniert nicht.\n\n---\n\n## Werkzeuge im Detail\n\n### `gguf-scanner.py` — Metadaten-Scanner\n\nScannt ein Verzeichnis rekursiv nach `.gguf`-Dateien und extrahiert deren GGUF-Metadaten.\n\n**Aufruf:**\n\n```bash\nuv run -m vram_model_calculator.gguf_scanner \u003cpfad\u003e\n# Beispiele:\nuv run -m vram_model_calculator.gguf_scanner ~/LMStudio/models/\nuv run -m vram_model_calculator.gguf_scanner .\n```\n\n**Was der Scanner liest:**\n\n| Feld | Beschreibung |\n|---|---|\n| `arch` | Modellarchitektur (`llama`, `qwen3`, `mistral`, …) |\n| `n_layers` | Anzahl der Transformer-Blöcke |\n| `n_embd` | Embedding-Dimension (Hidden Size) |\n| `n_heads` / `n_kv_heads` | Attention-Heads / KV-Heads |\n| `n_experts` / `n_experts_used` | MoE-Parameter (falls vorhanden) |\n| `quant` | Quantisierungstyp (`Q4_K_M`, `Q8_0`, `F16`, …) |\n| `n_ctx_orig` | Trainings-Kontextfenster des Modells |\n| `file_size_gb` | Dateigröße in GB (= Gewichts-VRAM) |\n\n**Inkrementeller Cache:**  \n`models_cache.json` wird beim nächsten Scan wiederverwendet. Eine Datei wird nur neu gescannt, wenn sie noch nicht im Cache ist oder sich ihre Dateigröße geändert hat. Bei veralteter Cache-Version (`_version`) wird der Cache automatisch neu aufgebaut.\n\n**Besonderheiten:**\n- Dateien, die mit `mmproj-` beginnen, werden als Vision-Projektor erkannt und separat gespeichert (`\"type\": \"mmproj\"`)\n- SSM-Modelle (z. B. LFM2, Nemotron-H) haben `n_kv_heads = 0` — kein KV-Cache\n- Fehlende Metadaten (z. B. `vocab_size`) werden über Fallback-Methoden ermittelt\n\n---\n\n### `vram-calculator.py` — Terminal-Rechner\n\nLiest `models_cache.json` und gibt für jedes LLM-Modell eine VRAM-Matrix im Terminal aus.\n\n**Aufruf:**\n\n```bash\nuv run -m vram_model_calculator.vram_calculator\n```\n\n**Konfiguration** (direkt im Skript):\n\n```python\nGPU_LIMITS = {\n    \"6GB (Entry)\":  6.0,\n    \"12GB (Mid)\":   12.0,\n    \"16GB (Pro)\":   16.0,\n    \"24GB (Ultra)\": 24.0,\n}\n\nUSECASES = {\n    \"Chat (8k)\":    8000,\n    \"Code (32k)\":   32000,\n    \"Doc (64k)\":    64000,\n    \"Rev (128k)\":   128000,\n    \"Res (256k)\":   256000,\n    \"Agent (512k)\": 512000,\n    \"Agent (1M)\":   1000000,\n}\n```\n\n**VRAM-Formel:**\n\n```\nGewichte-VRAM  = file_size_gb\nKV-Cache-VRAM  = (2 × n_layers × n_kv_heads × head_dim × ctx_tokens × 2) / 1024³\nGesamt         = Gewichte + KV-Cache\n```\n\n`head_dim = n_embd / n_heads`\n\nBei SSM-Modellen (`n_kv_heads = 0`) entfällt der KV-Cache-Term.\n\n**Farbcodierung:**\n\n| Symbol | Bedeutung |\n|---|---|\n| 🟢 | Passt bequem (≤ 85 % der GPU-Kapazität) |\n| 🟡 | Passt knapp (≤ 100 %) |\n| 🔴 | Passt nicht |\n\n---\n\n### `index.html` — Interaktive Webansicht\n\nEine reine Browser-Anwendung ohne Build-Schritt. Sie besteht aus drei Dateien:\n\n| Datei | Aufgabe |\n|---|---|\n| `index.html` | Struktur: Tabelle, Filter-Controls |\n| `filter.js` | Logik: JSON laden, VRAM berechnen, filtern, sortieren |\n| `style.css` | Dark-Mode-Design |\n\n**Funktionen:**\n\n- **Kontext-Auswahl** — wechselt die angezeigte VRAM-Spalte (Chat 8k bis Agent 1M)\n- **Architektur-Filter** — zeigt nur Modelle einer bestimmten Architektur\n- **Quantisierungs-Filter** — filtert nach Quant-Typ\n- **Suche** — Freitext-Suche über Modellname und Architektur\n- **Rote ausblenden** — vier Checkboxen (6 / 12 / 16 / 24 GB): blendet Modelle aus, die für die jeweilige GPU-Größe zu groß sind\n- **Sortierung** — jede Spalte ist klickbar, auf- und absteigend\n\n**GPU-Fit-Zellen:**\n\n| Symbol | CSS-Klasse | Bedeutung |\n|---|---|---|\n| `✓` | `fit-good` | Passt bequem (≤ 85 %) |\n| `~` | `fit-tight` | Passt knapp (≤ 100 %) |\n| `✗` | `fit-none` | Passt nicht |\n\nDer Tooltip am Modellnamen warnt, wenn der gewählte Kontext das ursprüngliche Trainings-Kontextfenster des Modells überschreitet.\n\n`filter.js` lädt `models_cache.json` per `fetch()` und führt dieselbe VRAM-Berechnung wie `vram-calculator.py` im Browser durch — kein Server-Rendering, kein Build-Prozess.\n\n---\n\n## Installation als CLI-Tool (Wheel)\n\nDas Projekt lässt sich als installiertes CLI-Paket nutzen — kein `python` davor, keine lokalen Skriptpfade.\n\n### Wheel bauen\n\n```bash\nuv build\n# Erstellt:\n#   dist/vram_model_calculator-0.1.0-py3-none-any.whl\n#   dist/vram_model_calculator-0.1.0.tar.gz\n```\n\n### Global installieren (empfohlen)\n\n```bash\nuv tool install dist/vram_model_calculator-0.1.0-py3-none-any.whl\n```\n\nDanach stehen zwei Kommandos systemweit bereit:\n\n```bash\ngguf-scanner ~/LMStudio/models/\nvram-calculator\n```\n\n### Ohne Installation testen\n\n```bash\nuv run --with dist/vram_model_calculator-0.1.0-py3-none-any.whl gguf-scanner ~/LMStudio/models/\nuv run --with dist/vram_model_calculator-0.1.0-py3-none-any.whl vram-calculator\n```\n\n### Neu installieren / aktualisieren\n\n```bash\n# Wheel neu bauen\nuv build\n\n# Cache leeren (wichtig damit uv die neue Version zieht)\nuv cache clean vram-model-calculator\n\n# Neu installieren\nuv tool install --force dist/vram_model_calculator-0.1.0-py3-none-any.whl\n```\n\n### Deinstallieren\n\n```bash\nuv tool uninstall vram-model-calculator\n```\n\n---\n\n## Projektstruktur\n\n```\nvram-model-calculator/\n├── vram_model_calculator/        # Installiertes Python-Paket\n│   ├── __init__.py\n│   ├── gguf_scanner.py           # Schritt 1: GGUF-Dateien scannen → models_cache.json\n│   └── vram_calculator.py        # Schritt 2 (optional): Terminal-Ausgabe\n├── models_cache.json             # Generiert vom Scanner (im Arbeitsverzeichnis)\n├── index.html                    # Browser-UI\n├── filter.js                     # Logik der Browser-UI\n├── style.css                     # Styles der Browser-UI\n├── dist/                         # Build-Artefakte (wheel + sdist)\n└── pyproject.toml                # Paket-Metadaten und Abhängigkeiten\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwlanboy%2Fvram-model-calculator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwlanboy%2Fvram-model-calculator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwlanboy%2Fvram-model-calculator/lists"}