From 333e4a85d18ebd92d72ff68ca4f6fa2c30aab170 Mon Sep 17 00:00:00 2001 From: duffyduck Date: Wed, 25 Nov 2026 15:44:36 +0100 Subject: [PATCH] feat(diagnostic): RAM-Auslastung der Box im Grafikkarten-Monitor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit node_stats liest zusaetzlich /proc/meminfo und schickt im Live-Stream ein ram-Feld (used/total MB). Der Karten-Monitor zeigt pro Box eine eigene RAM-Zeile ueber den Karten — macht die in den RAM ausgelagerten MoE-Experten sichtbar, die auf der GPU nicht auftauchen. Kein neuer Message-Typ (nur neues Feld in node_stats), RVS-Allow-List unveraendert. node_stats.py in alle vier Worker-Kopien gespiegelt. Co-Authored-By: Claude Opus 4.8 --- diagnostic/index.html | 20 +++++++++++++++++++- xtts/f5tts/node_stats.py | 22 +++++++++++++++++++++- xtts/llm-adapter/node_stats.py | 22 +++++++++++++++++++++- xtts/voxtral/node_stats.py | 22 +++++++++++++++++++++- xtts/whisper/node_stats.py | 22 +++++++++++++++++++++- 5 files changed, 103 insertions(+), 5 deletions(-) diff --git a/diagnostic/index.html b/diagnostic/index.html index 49d1127..b9712fb 100644 --- a/diagnostic/index.html +++ b/diagnostic/index.html @@ -5585,12 +5585,14 @@ // die echte steht im worker.gpus). const _cardLoadStreams = new Map(); // instanceId → {node, gpus, single} const _cardLoad = new Map(); // node|uuid → {node, index, name, util, ..., hist: []} + const _nodeRam = new Map(); // node → {ramUsed, ramTotal, ts} (System-RAM der Box) let _cardLoadTimer = null; /** onlyNode: nur diese Box (Button in der Compute-Flotte); leer = alle */ function openCardLoad(onlyNode) { document.getElementById('card-load-modal').style.display = 'flex'; document.getElementById('card-load-scope').textContent = onlyNode ? ' · ' + onlyNode : ''; _cardLoad.clear(); + _nodeRam.clear(); _cardLoadStreams.clear(); const byNode = {}; for (const w of workers) { @@ -5621,7 +5623,9 @@ } function onCardLoadStats(p) { const src = _cardLoadStreams.get(p.instanceId); - if (!src || !Array.isArray(p.cards)) return; + if (!src) return; + if (p.ram && (p.ram.ramTotal || p.ram.ramUsed)) _nodeRam.set(src.node, { ...p.ram, ts: Date.now() }); + if (!Array.isArray(p.cards)) { renderCardLoad(); return; } for (const c of p.cards) { // Einzel-Dienst: Container-Nummer (0) durch die echte Karte ersetzen const index = src.single && src.gpus && !src.gpus.includes(',') ? src.gpus : c.index; @@ -5679,8 +5683,22 @@ '
' + (jobs.length ? jobs.map(escapeHtml).join(' · ') : 'nichts zugewiesen') + '
' + ''; }).join('') : '
warte auf Werte … (Box mit altem Stand? Dann liefert sie noch keine Werte pro Karte.)
'; + const ram = _nodeRam.get(node); + let ramRow = ''; + if (ram && ram.ramTotal) { + const ramPct = ram.ramUsed / ram.ramTotal * 100; + const ramColor = ramPct >= 92 ? '#FF6B6B' : ramPct >= 80 ? '#FFB020' : '#B392F0'; + ramRow = '
' + + '
' + + 'Arbeitsspeicher (RAM)' + _bar(ramPct, ramColor) + + '' + (ram.ramUsed / 1024).toFixed(1) + ' / ' + (ram.ramTotal / 1024).toFixed(0) + ' GB' + + '
' + + '
inkl. in den RAM ausgelagerter MoE-Experten
' + + '
'; + } return '
🖥 ' + escapeHtml(node) + (stale ? ' · keine neuen Werte' : '') + '
' + + ramRow + '
' + inner + '
'; }).join(''); } diff --git a/xtts/f5tts/node_stats.py b/xtts/f5tts/node_stats.py index 3e0074a..bbb4389 100644 --- a/xtts/f5tts/node_stats.py +++ b/xtts/f5tts/node_stats.py @@ -125,6 +125,25 @@ class NodeStats: txt = await _run_cmd("nvidia-smi") return txt or "nvidia-smi nicht verfuegbar" + # ── System-RAM ────────────────────────────────────────── + def _query_ram(self) -> dict: + """Arbeitsspeicher der Box (used/total in MB). Wichtig, seit MoE-Modelle + Experten in den RAM auslagern — auf der GPU sieht man das sonst nicht.""" + try: + info = {} + with open("/proc/meminfo") as f: + for line in f: + k, _, rest = line.partition(":") + info[k.strip()] = rest + def kb(key): + return int(info.get(key, "0").split()[0]) + total = kb("MemTotal") + avail = kb("MemAvailable") + used = max(0, total - avail) + return {"ramUsed": round(used / 1024), "ramTotal": round(total / 1024)} + except Exception: + return {} + # ── Sampler (Verlauf) ─────────────────────────────────── async def run_sampler(self) -> None: while True: @@ -154,9 +173,10 @@ class NodeStats: g = await self._query_gpu() smi = await self._nvidia_smi_text() cards = await self._query_cards() + ram = self._query_ram() await send(ws, "node_stats", { "instanceId": self.instance_id, "node": self.node_name, - "nvidiaSmi": smi, "cards": cards, **g, + "nvidiaSmi": smi, "cards": cards, "ram": ram, **g, }) await asyncio.sleep(1) except asyncio.CancelledError: diff --git a/xtts/llm-adapter/node_stats.py b/xtts/llm-adapter/node_stats.py index 3e0074a..bbb4389 100644 --- a/xtts/llm-adapter/node_stats.py +++ b/xtts/llm-adapter/node_stats.py @@ -125,6 +125,25 @@ class NodeStats: txt = await _run_cmd("nvidia-smi") return txt or "nvidia-smi nicht verfuegbar" + # ── System-RAM ────────────────────────────────────────── + def _query_ram(self) -> dict: + """Arbeitsspeicher der Box (used/total in MB). Wichtig, seit MoE-Modelle + Experten in den RAM auslagern — auf der GPU sieht man das sonst nicht.""" + try: + info = {} + with open("/proc/meminfo") as f: + for line in f: + k, _, rest = line.partition(":") + info[k.strip()] = rest + def kb(key): + return int(info.get(key, "0").split()[0]) + total = kb("MemTotal") + avail = kb("MemAvailable") + used = max(0, total - avail) + return {"ramUsed": round(used / 1024), "ramTotal": round(total / 1024)} + except Exception: + return {} + # ── Sampler (Verlauf) ─────────────────────────────────── async def run_sampler(self) -> None: while True: @@ -154,9 +173,10 @@ class NodeStats: g = await self._query_gpu() smi = await self._nvidia_smi_text() cards = await self._query_cards() + ram = self._query_ram() await send(ws, "node_stats", { "instanceId": self.instance_id, "node": self.node_name, - "nvidiaSmi": smi, "cards": cards, **g, + "nvidiaSmi": smi, "cards": cards, "ram": ram, **g, }) await asyncio.sleep(1) except asyncio.CancelledError: diff --git a/xtts/voxtral/node_stats.py b/xtts/voxtral/node_stats.py index 3e0074a..bbb4389 100644 --- a/xtts/voxtral/node_stats.py +++ b/xtts/voxtral/node_stats.py @@ -125,6 +125,25 @@ class NodeStats: txt = await _run_cmd("nvidia-smi") return txt or "nvidia-smi nicht verfuegbar" + # ── System-RAM ────────────────────────────────────────── + def _query_ram(self) -> dict: + """Arbeitsspeicher der Box (used/total in MB). Wichtig, seit MoE-Modelle + Experten in den RAM auslagern — auf der GPU sieht man das sonst nicht.""" + try: + info = {} + with open("/proc/meminfo") as f: + for line in f: + k, _, rest = line.partition(":") + info[k.strip()] = rest + def kb(key): + return int(info.get(key, "0").split()[0]) + total = kb("MemTotal") + avail = kb("MemAvailable") + used = max(0, total - avail) + return {"ramUsed": round(used / 1024), "ramTotal": round(total / 1024)} + except Exception: + return {} + # ── Sampler (Verlauf) ─────────────────────────────────── async def run_sampler(self) -> None: while True: @@ -154,9 +173,10 @@ class NodeStats: g = await self._query_gpu() smi = await self._nvidia_smi_text() cards = await self._query_cards() + ram = self._query_ram() await send(ws, "node_stats", { "instanceId": self.instance_id, "node": self.node_name, - "nvidiaSmi": smi, "cards": cards, **g, + "nvidiaSmi": smi, "cards": cards, "ram": ram, **g, }) await asyncio.sleep(1) except asyncio.CancelledError: diff --git a/xtts/whisper/node_stats.py b/xtts/whisper/node_stats.py index 3e0074a..bbb4389 100644 --- a/xtts/whisper/node_stats.py +++ b/xtts/whisper/node_stats.py @@ -125,6 +125,25 @@ class NodeStats: txt = await _run_cmd("nvidia-smi") return txt or "nvidia-smi nicht verfuegbar" + # ── System-RAM ────────────────────────────────────────── + def _query_ram(self) -> dict: + """Arbeitsspeicher der Box (used/total in MB). Wichtig, seit MoE-Modelle + Experten in den RAM auslagern — auf der GPU sieht man das sonst nicht.""" + try: + info = {} + with open("/proc/meminfo") as f: + for line in f: + k, _, rest = line.partition(":") + info[k.strip()] = rest + def kb(key): + return int(info.get(key, "0").split()[0]) + total = kb("MemTotal") + avail = kb("MemAvailable") + used = max(0, total - avail) + return {"ramUsed": round(used / 1024), "ramTotal": round(total / 1024)} + except Exception: + return {} + # ── Sampler (Verlauf) ─────────────────────────────────── async def run_sampler(self) -> None: while True: @@ -154,9 +173,10 @@ class NodeStats: g = await self._query_gpu() smi = await self._nvidia_smi_text() cards = await self._query_cards() + ram = self._query_ram() await send(ws, "node_stats", { "instanceId": self.instance_id, "node": self.node_name, - "nvidiaSmi": smi, "cards": cards, **g, + "nvidiaSmi": smi, "cards": cards, "ram": ram, **g, }) await asyncio.sleep(1) except asyncio.CancelledError: