From b69dee1d3a640f6a04115fed3bb93789d68d53b6 Mon Sep 17 00:00:00 2001 From: Folzo Date: Sun, 12 Apr 2026 12:25:45 +0200 Subject: [PATCH] =?UTF-8?q?docs:=20Mettre=20=C3=A0=20jour=20journal=20de?= =?UTF-8?q?=20session=202026-04-12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - État final des scripts et services - ComfyUI memory manager avec restart container - Beszel wake service - Résumé commits --- docs/SESSION-2026-04-12-RAM-BESZEL.md | 197 ++++++++++++++------------ 1 file changed, 103 insertions(+), 94 deletions(-) diff --git a/docs/SESSION-2026-04-12-RAM-BESZEL.md b/docs/SESSION-2026-04-12-RAM-BESZEL.md index 85f05da..fa26532 100644 --- a/docs/SESSION-2026-04-12-RAM-BESZEL.md +++ b/docs/SESSION-2026-04-12-RAM-BESZEL.md @@ -15,6 +15,8 @@ | kreuzberg | 1 GB | 3.1% | | effi-stt | 13 MB | 0.04% | +**Cause**: ComfyUI charge les modèles en RAM (pas juste VRAM) et ne les décharge jamais. + --- ## 2. Solutions Implémentées @@ -24,10 +26,10 @@ **Fichier**: `effi-stt/main.py` **Modifications**: -- Ajout d'un timer d'inactivité (défaut: 300s) +- Timer d'inactivité (défaut: 300s) - Le modèle Whisper est chargé à la première requête - Après 300s d'inactivité, le modèle est déchargé -- `gc.collect()` libéré la mémoire +- `gc.collect()` libère la mémoire **Nouveaux endpoints**: - `POST /unload` - déchargement manuel @@ -37,28 +39,18 @@ **Variables d'environnement**: - `INACTIVITY_TIMEOUT=300` (secondes) -**Commit**: `f69dda5` - --- -### B. ComfyUI - Déchargement VRAM après inactivité +### B. ComfyUI - Redémarrage container après inactivité -**Fichier**: `scripts/comfyui-unload-monitor.py` +**Fichier**: `scripts/comfyui-memory-manager.py` **Fonctionnement**: -- Script Python qui vérifie l'usage VRAM toutes les 60s -- Après 300s d'inactivité avec VRAM utilisée: - - Exécute le workflow `UnloadAllModelsNode` - - Appelle `gc.collect()` + `torch.cuda.empty_cache()` +- Vérifie VRAM, queue, et history toutes les 60s +- Après 600s (10 min) d'inactivité + VRAM < 1% + RAM > 5GB +- Redémarre le container ComfyUI pour libérer la RAM -**Options**: -```bash ---interval 60 # Intervalle de vérification ---timeout 300 # Timeout d'inactivité ---debug # Mode debug -``` - -**Commit**: `f69dda5` +**Service systemd**: `systemd/comfyui-memory-manager.service` --- @@ -73,11 +65,9 @@ **Note**: Kreuzberg est un binaire Rust pré-compilé, donc un restart container est nécessaire pour libérer la mémoire. -**Commit**: `f69dda5` - --- -### D. Installation Beszel Monitoring +### D. Beszel - Monitoring Infrastructure **Architecture**: ``` @@ -93,27 +83,16 @@ NAS Synology (192.168.1.25) - Hub Beszel (port 8090) | FolzoCorp | `/home/folzo/Documents/OpenCode/Projets/Effi/beszel` | | EffiServer | `/home/effi/effi/beszel` | -**Fichiers de configuration**: -- `beszel/docker-compose-hub.yml` - Hub Synology -- `beszel/docker-compose-agent-folzocorp.yml` - Agent FolzoCorp -- `beszel/docker-compose-agent-effiserver.yml` - Agent EffiServer - **Monitoring GPU**: - FolzoCorp: `amd_sysfs` collector (AMD RX 7800 XT) - EffiServer: `SKIP_GPU=true` (pas de GPU) -**Commits**: `8b1338f`, `5b677d8`, `8b6f967` - --- ### E. Client API Beszel pour Effi **Fichier**: `scripts/beszel_client.py` -**Fonctionnement**: -- Permet à Effi d'interroger l'API Beszel -- Récupère les métriques CPU, RAM, VRAM, GPU - **Utilisation**: ```bash export BESZEL_URL=http://192.168.1.25:8090 @@ -125,72 +104,103 @@ python3 scripts/beszel_client.py --system folzocorp --check stats python3 scripts/beszel_client.py --system folzocorp --check alerts ``` -**Commit**: `8b1338f` +--- + +### F. Service Beszel Wake - Redémarrage après veille + +**Fichier**: `systemd/beszel-agent-wake.service` + +**Fonctionnement**: +- Redémarre le container `beszel-agent` à chaque sortie de veille +- Asegure que Beszel envoie les données dès que le PC est allumé --- -## 3. État Actuel RAM (après modifications) +## 3. Services systemd Installés -**-date**: 12 Avril 2026, 09:55 - -``` -Mem: 31Gi used / 29Gi -Swap: 8Gi used / 8Gi (100%) - -Container RAM: -- ComfyUI: 15.19 GiB (48.61%) ← Principal consommateur -- kreuzberg: 982.8 MiB (3.07%) -- beszel-agent: 5.4 MiB (0.02%) -``` - -**Note**: Les scripts de déchargement ne sont pas encore lancés. ComfyUI occupe toujours 15GB. - ---- - -## 4. Prochaines Étapes - -### A. Lancer les monitors mémoire +| Service | Description | Status | +|---------|-------------|--------| +| `comfyui-memory-manager` | Redémarre ComfyUI après inactivité | ✅ Actif | +| `beszel-agent-wake` | Redémarre Beszel au réveil | ✅ Actif | +**Commandes**: ```bash -# Sur FolzoCorp -nohup python3 scripts/comfyui-unload-monitor.py > /var/log/comfyui-unload.log 2>&1 & -nohup python3 scripts/kreuzberg-memory-manager.py > /var/log/kreuzberg-mem.log 2>&1 & -``` +# Statut +sudo systemctl status comfyui-memory-manager +sudo systemctl status beszel-agent-wake -### B. Redémarrer effi-stt avec les nouvelles variables - -```bash -cd effi-stt -docker compose down -docker compose up -d --build -``` - -### C. Vérifier la baisse de RAM après inactivity timeout - ---- - -## 5. Commandes Utiles - -### Vérifier RAM -```bash -free -h -docker stats --no-stream -``` - -### Logs monitors -```bash -tail -f /var/log/comfyui-unload.log -tail -f /var/log/kreuzberg-mem.log -``` - -### Statut Beszel -```bash -curl http://192.168.1.25:8090/api/systems -H "Authorization: Bearer " +# Logs +journalctl -u comfyui-memory-manager -f +journalctl -u beszel-agent-wake -f ``` --- -## 6. Liens +## 4. Fichiers Créés/Modifiés + +### Scripts +| Fichier | Description | +|---------|-------------| +| `effi-stt/main.py` | Ajout timeout inactivité | +| `scripts/comfyui-memory-manager.py` | Monitor + restart ComfyUI | +| `scripts/kreuzberg-memory-manager.py` | Monitor + restart Kreuzberg | +| `scripts/beszel_client.py` | Client API Beszel | +| `scripts/start-memory-monitors.sh` | Script démarrage monitors | + +### Systemd +| Fichier | Description | +|---------|-------------| +| `systemd/comfyui-memory-manager.service` | Service ComfyUI manager | +| `systemd/kreuzberg-memory-manager.service` | Service Kreuzberg manager | +| `systemd/beszel-agent-wake.service` | Service wake Beszel | + +### Beszel +| Fichier | Description | +|---------|-------------| +| `beszel/docker-compose-hub.yml` | Hub Synology | +| `beszel/docker-compose-agent-folzocorp.yml` | Agent FolzoCorp | +| `beszel/docker-compose-agent-effiserver.yml` | Agent EffiServer | + +--- + +## 5. État Actuel RAM + +**-date**: 12 Avril 2026, 12:20 + +``` +Mem: 25Gi used / 32Gi +VRAM: 1.18 GB / 17 GB (AMD RX 7800 XT) +``` + +**Containers**: +| Container | RAM | Observation | +|-----------|-----|-------------| +| ComfyUI | ~18 GB | shm_size réservé, VRAM ~500 MB | +| effi-stt | ~20 MB | Modèle déchargé si inactif | +| kreuzberg | ~5 MB | Restart si > 2GB | +| openedai-speech | ~15 MB | TTS - GPU, RAM légère | + +**VRAM détail**: +- ComfyUI: ~500 MB (modèles actifs) +- ROCm overhead: ~700 MB + +--- + +## 6. Résumé Commits Gitea + +| Commit | Description | +|--------|-------------| +| `f69dda5` | feat(memory): Déchargement automatique mémoire | +| `8b1338f` | feat(beszel): Installation Beszel infrastructure | +| `5b677d8` | fix(beszel): Mise à jour chemins installation | +| `8b6f967` | fix(beszel): Retrait group_add pour Fedora | +| `e528e25` | feat: Add systemd services for memory monitors | +| `7439033` | fix: Corriger script ComfyUI monitor | +| `2ca4235` | feat: Add ComfyUI memory manager with container restart | + +--- + +## 7. Liens Utiles - [Beszel GitHub](https://github.com/henrygd/beszel) - [Documentation Beszel](https://beszel.dev) @@ -199,11 +209,10 @@ curl http://192.168.1.25:8090/api/systems -H "Authorization: Bearer " --- -## 7. Résumé Commits Gitea +## 8. Notes -| Commit | Description | -|--------|-------------| -| `f69dda5` | feat(memory): Déchargement automatique mémoire | -| `8b1338f` | feat(beszel): Installation Beszel infrastructure | -| `5b677d8` | fix(beszel): Mise à jour chemins installation | -| `8b6f967` | fix(beszel): Retrait group_add pour Fedora | +- **ComfyUI**: VRAM légère mais RAM élevée. Redémarrage container libère ~18 GB. +- **effi-stt**: Modèle CPU, se décharge correctement après timeout. +- **Kreuzberg**: Restart container après inactivité si > 2GB. +- **openedai-speech**: ~15 MB RAM, négligeable, utilise GPU pour modèles. +- **Beszel**: Wake service assure monitoring même après veille.