diff --git a/docker/docker-compose.gpu-amd.yml b/docker/docker-compose.gpu-amd.yml new file mode 100644 index 0000000..d8874b6 --- /dev/null +++ b/docker/docker-compose.gpu-amd.yml @@ -0,0 +1,12 @@ +# Optional AMD device passthrough for Agent GPU inventory. +# The current Agent image still runs ONNX inference on CPU. +services: + heimdall-agent: + profiles: + - gpu-amd-inventory + devices: + - /dev/kfd:/dev/kfd + - /dev/dri:/dev/dri + group_add: + - "${VIDEO_GID:-44}" + - "${RENDER_GID:-109}" diff --git a/docker/docker-compose.gpu-intel.yml b/docker/docker-compose.gpu-intel.yml new file mode 100644 index 0000000..6dd56f3 --- /dev/null +++ b/docker/docker-compose.gpu-intel.yml @@ -0,0 +1,11 @@ +# Optional Intel render-device passthrough for Agent GPU inventory. +# The current Agent image still runs ONNX inference on CPU. +services: + heimdall-agent: + profiles: + - gpu-intel-inventory + devices: + - /dev/dri:/dev/dri + group_add: + - "${VIDEO_GID:-44}" + - "${RENDER_GID:-109}" diff --git a/docker/docker-compose.gpu-nvidia.yml b/docker/docker-compose.gpu-nvidia.yml new file mode 100644 index 0000000..59eb703 --- /dev/null +++ b/docker/docker-compose.gpu-nvidia.yml @@ -0,0 +1,13 @@ +# Optional NVIDIA device passthrough for Agent GPU inventory. +# The current Agent image still runs ONNX inference on CPU. +services: + heimdall-agent: + profiles: + - gpu-nvidia-inventory + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: all + capabilities: [gpu] diff --git a/docker/docker-compose.prod.yml b/docker/docker-compose.prod.yml index 66b08ea..e31b31d 100644 --- a/docker/docker-compose.prod.yml +++ b/docker/docker-compose.prod.yml @@ -154,32 +154,8 @@ services: Agent__AgentName: ${HEIMDALL_AGENT_NAME:-agent-01} Agent__HeartbeatIntervalSeconds: ${HEIMDALL_HEARTBEAT_INTERVAL:-30} Agent__StateDirectory: /var/lib/heimdall - # ONNX Runtime GPU provider selection - ORT_PROVIDER: ${AGENT_ORT_PROVIDER:-CUDA} - ORT_CUDA_DEVICE_ID: ${AGENT_CUDA_DEVICE_ID:-0} - # GPU device exposure (NVIDIA CUDA, AMD ROCm, Intel VAAPI/iGPU) - # Override in docker-compose.local.yml for specific GPU hardware: - # deploy: - # resources: - # reservations: - # devices: - # - driver: nvidia - # count: 1 - # capabilities: [gpu] - # Or for AMD ROCm: - # devices: - # - /dev/kfd:/dev/kfd - # - /dev/dri:/dev/dri - # Or for Intel iGPU/VAAPI: - # devices: - # - /dev/dri:/dev/dri - deploy: - resources: - reservations: - devices: - - driver: nvidia - count: 1 - capabilities: [gpu] + # The published Agent image runs ONNX inference on CPU. Optional GPU + # passthrough overlays are only for device inventory/experimentation. healthcheck: test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:8081/healthz"] interval: 30s diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index a660a7f..5423a42 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -118,9 +118,6 @@ services: build: context: .. dockerfile: docker/Dockerfile.agent - args: - # Select GPU runtime: nvidia | amd | intel | cpu (default) - TARGET_RUNTIME: ${AGENT_RUNTIME:-cpu} # Host network: the agent must see the real camera LAN to run discovery. # On a bridge network it only sees 172.x → the scanner skips (no local subnet). network_mode: host @@ -137,35 +134,9 @@ services: Agent__HeartbeatIntervalSeconds: ${HEIMDALL_HEARTBEAT_INTERVAL:-30} Agent__StateDirectory: /var/lib/heimdall Agent__RegistrationMaxRetries: ${HEIMDALL_REGISTRATION_RETRIES:-5} - # ONNX Runtime GPU provider selection - ORT_PROVIDER: ${AGENT_ORT_PROVIDER:-CUDA} - ORT_CUDA_DEVICE_ID: ${AGENT_CUDA_DEVICE_ID:-0} volumes: - agent_state:/var/lib/heimdall user: "1654:1654" - # GPU device exposure (NVIDIA CUDA, AMD ROCm, Intel VAAPI/iGPU) - # Override in docker-compose.local.yml for specific GPU hardware: - # deploy: - # resources: - # reservations: - # devices: - # - driver: nvidia - # count: 1 - # capabilities: [gpu] - # Or for AMD ROCm: - # devices: - # - /dev/kfd:/dev/kfd - # - /dev/dri:/dev/dri - # Or for Intel iGPU/VAAPI: - # devices: - # - /dev/dri:/dev/dri - deploy: - resources: - reservations: - devices: - - driver: nvidia - count: 1 - capabilities: [gpu] healthcheck: test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:8081/healthz"] interval: 30s diff --git a/docs/README.md b/docs/README.md index 99d62c4..20635c0 100644 --- a/docs/README.md +++ b/docs/README.md @@ -14,6 +14,7 @@ vidéosurveillance IA locale, multi-site, auto-hébergée. | **Plan d'implémentation historique** (MVP juillet 2026) | `docs/implementation.md` | | **Maquettes UI Blazor** détaillées | `docs/ui-pages.md` | | **Application web installable (PWA)** | [Audit et plan PWA](pwa.md) | +| **GPU Agent** | [Accès matériel et état de l'inférence](gpu-runtime.md) | ## 🏗️ Domaines fonctionnels @@ -35,6 +36,7 @@ vidéosurveillance IA locale, multi-site, auto-hébergée. | **Hangfire (jobs)** | `docs/hangfire-usage.md` | Configuration actuelle et jobs présents; vérifier l'état des parcours dans l'audit | | **SignalR (temps réel)** | `docs/signalr-usage.md` | Hubs et contrats documentés; état du streaming live dans l'audit | | **Déploiement Docker** | `docs/specs.md` (§30) | Containers, GPU passthrough, docker-compose | +| **GPU Agent** | [Accès matériel et état de l'inférence](gpu-runtime.md) | Profils facultatifs; l'inférence ONNX publiée reste CPU | ## 📐 Structure du projet diff --git a/docs/gpu-runtime.md b/docs/gpu-runtime.md new file mode 100644 index 0000000..d0f1675 --- /dev/null +++ b/docs/gpu-runtime.md @@ -0,0 +1,38 @@ +# GPU device access and inference status + +The default Agent uses `CPUExecutionProvider`. The published Agent image only +contains the CPU ONNX Runtime package. GPU detection and inventory report host +hardware; they do not mean that frame inference is running on that hardware. + +The default Compose files do not require a GPU. Optional overlays expose a +device to the Agent for inventory and hardware experiments: + +```sh +# NVIDIA +docker compose --env-file docker/.env \ + -f docker/docker-compose.yml \ + -f docker/docker-compose.gpu-nvidia.yml \ + --profile gpu-nvidia-inventory up -d heimdall-agent + +# AMD ROCm devices +docker compose --env-file docker/.env \ + -f docker/docker-compose.yml \ + -f docker/docker-compose.gpu-amd.yml \ + --profile gpu-amd-inventory up -d heimdall-agent + +# Intel render device +docker compose --env-file docker/.env \ + -f docker/docker-compose.yml \ + -f docker/docker-compose.gpu-intel.yml \ + --profile gpu-intel-inventory up -d heimdall-agent +``` + +Use the same overlay with `docker/docker-compose.prod.yml` in place of the +development file. For Intel and AMD hosts, set `VIDEO_GID` and `RENDER_GID` to +the host group IDs that can access `/dev/dri`. The NVIDIA option requires the +NVIDIA Container Toolkit and Docker Compose GPU device reservations. + +These overlays only expose devices for Agent inventory. They do not enable +GPU-accelerated ONNX inference. Enabling that requires a GPU-specific runtime +image, selecting and reporting the provider actually attached to the ONNX +session, and validation on real supported hardware with a CPU fallback. diff --git a/scripts/ci/validate-compose.sh b/scripts/ci/validate-compose.sh index d3c64fa..a4b0ddc 100644 --- a/scripts/ci/validate-compose.sh +++ b/scripts/ci/validate-compose.sh @@ -4,6 +4,12 @@ set -euo pipefail docker compose --env-file .env.example -f docker/docker-compose.yml config --quiet AGENT_IMAGE_REFERENCE=heimdall-agent:ci docker compose --env-file .env.example -f docker/docker-compose.prod.yml config --quiet docker compose --env-file .env.example -f docker/docker-compose.yml -f docker/docker-compose.backup.yml config --quiet +docker compose --env-file .env.example -f docker/docker-compose.yml -f docker/docker-compose.gpu-nvidia.yml --profile gpu-nvidia-inventory config --quiet +docker compose --env-file .env.example -f docker/docker-compose.yml -f docker/docker-compose.gpu-amd.yml --profile gpu-amd-inventory config --quiet +docker compose --env-file .env.example -f docker/docker-compose.yml -f docker/docker-compose.gpu-intel.yml --profile gpu-intel-inventory config --quiet +AGENT_IMAGE_REFERENCE=heimdall-agent:ci docker compose --env-file .env.example -f docker/docker-compose.prod.yml -f docker/docker-compose.gpu-nvidia.yml --profile gpu-nvidia-inventory config --quiet +AGENT_IMAGE_REFERENCE=heimdall-agent:ci docker compose --env-file .env.example -f docker/docker-compose.prod.yml -f docker/docker-compose.gpu-amd.yml --profile gpu-amd-inventory config --quiet +AGENT_IMAGE_REFERENCE=heimdall-agent:ci docker compose --env-file .env.example -f docker/docker-compose.prod.yml -f docker/docker-compose.gpu-intel.yml --profile gpu-intel-inventory config --quiet for required in JWT__KEY JWT__REFRESHKEY HEIMDALL_SITE_TOKEN DATABASE_URL POSTGRES_PASSWORD RUSTFS_ACCESS_KEY RUSTFS_SECRET_KEY COTURN_SECRET; do if env "$required=" docker compose --env-file .env.example -f docker/docker-compose.yml config --quiet >/dev/null 2>&1; then echo "Compose accepted missing required variable: $required" >&2 diff --git a/todo.md b/todo.md index 42972b8..0167e6c 100644 --- a/todo.md +++ b/todo.md @@ -38,7 +38,7 @@ Ce fichier remplace les rapports de `docs/audits/` et constitue le suivi courant - [ ] **FEAT-01** Définir codecs, spectateurs et budget latence ; implémenter live WebRTC/ICE/TURN, sessions autorisées, audio/PTZ compatibles et libération des ressources. Tester LAN et réseau externe. - [ ] **FEAT-02** Implémenter enregistrement continu/événement, segments et index temporel, upload repris, replay/range/export autorisés, quotas et purge complète. - [ ] **FEAT-03 / UI-02** Évaluer modèles/licences visage et plaques, persister `PersonId`/`VehicleId` et lier les événements ; vérifier historique paginé sans confusion d'identité, conservation et suppression des données biométriques. -- [ ] **GPU #77** Ajouter profils Compose optionnels et détection du backend effectif ; garder CPU par défaut et tester GPU réel plus fallback CPU. +- [ ] **GPU #77** Les Compose CPU n'exigent plus NVIDIA et n'annoncent plus un `ORT_PROVIDER=CUDA` ignoré. Des overlays optionnels exposent NVIDIA/AMD/Intel à l'inventaire; l'inférence ONNX de l'image Agent reste CPU. Restent une image/runtime GPU, la détection du fournisseur réellement attaché à la session, et les validations GPU réel + fallback CPU. - [ ] **Inventaire #86** Historiser CPU/RAM/disque/température GPU, fournir courbes 24 h/7 j et capacité par site, avec index et purge bornée. - [ ] **mDNS #81** La PR #78 fait de l'Agent la source unique des probes HomeKit sur le LAN caméra ; Central persiste et restitue catégorie, appairage et port, et la fusion conserve l'annonce mDNS même si le scan TCP a vu l'IP d'abord. Le client partagé assemble PTR/SRV/TXT/A, décode `ci` et `sf`, et filtre les catégories 17/18. La CI #246 a passé build, tests et scans d'images ; reste une validation sur LAN avec caméra/sonnette réelles. - [ ] **UI groupes #138 / accès #134** Finaliser maquette et validation produit, puis vérifier l'union accès direct/groupe et les priorités dans l'interface.