Co-authored-by: Arnaud Dartois <admin@tordais.cc>
6.8 KiB
name, description
| name | description |
|---|---|
| heimdall-gpu-inference | Build and verify Agent ONNX Runtime provider selection, CPU fallback, and GPU package variants in Heimdall. |
Heimdall Agent ONNX inference
Use this skill when changing ONNX Runtime packages, execution provider configuration, Agent inference startup, or GPU deployment support.
Project-specific workflow
-
The default Agent build and published
docker/Dockerfile.agentremain CPU-only. Do not add NVIDIA runtime/device requirements to the default Agent Compose files. CUDA support is opt-in throughdocker/Dockerfile.agent.gpu,docker/docker-compose.agent.dev.gpu-nvidia.yml, and a separately signed release image manifest. -
Keep the GPU summary in
docs/README.mdaligned withdocs/gpu-runtime.md: the default Agent remains CPU-only, an optional signed NVIDIA/CUDA amd64 image is published, and physical CUDA execution remains unvalidated until exercised on compatible hardware. Do not collapse these states into “published inference is CPU-only” or imply hardware validation from package/image publication. -
Keep technical-spec summaries consistent with
AgentOptions,AnalysisMode, ONNX provider selection, anddocs/gpu-runtime.md: distinguish CPU-default inference and optional NVIDIA/CUDA inference from GPU inventory and FFmpeg media handling. AMD/Intel device visibility or detected NVENC/QSV/VAAPI capability is not evidence that ONNX inference or a media pipeline uses those accelerators. Treat remote broker mode as configurable behavior, not a validated inter-site deployment; do not publish throughput estimates without reproducible measurements and hardware/method details. -
Configure provider choice through
Agent:InferenceExecutionProvider(environment variableAgent__InferenceExecutionProvider).CPUis the default.CUDAis optional and valid only in a runtime containing the official ONNX Runtime GPU package plus compatible CUDA/cuDNN native libraries and host driver access. -
Keep the CPU and GPU NuGet dependency graphs in their separate lock files. Restore each variant explicitly and in locked mode after changing dependencies:
dotnet restore src/Heimdall.Agent/Heimdall.Agent.csproj --locked-mode dotnet restore src/Heimdall.Agent/Heimdall.Agent.csproj -p:HeimdallOnnxRuntime=GPU --locked-mode -
The Agent checks for detected NVIDIA hardware before enumerating ONNX providers or creating a session; some ONNX Runtime GPU builds can fault during native provider discovery when no driver device is attached, before managed fallback handling is possible. It reports the provider configured on the resulting session. If CUDA is requested but unavailable or session construction fails, log the reason without sensitive payloads and construct a CPU session. Keep provider selection isolated behind
OnnxExecutionProviderSelectionso the fallback can be tested without hardware. -
Add tests for CPU-only selection, successful CUDA selection, missing CUDA provider, and CUDA session initialization failure. Also exercise the repository YOLO fixture with the CPU provider so package changes preserve real inference.
-
Test the default Agent test suite and the GPU package variant where the local machine permits. GPU package tests may need a larger non-
/tmpoutput directory because ONNX GPU and image-processing NuGet packages ship native assets for multiple operating systems. The real-model test searches upward from the test output formodels/yolov8n.onnx; keep output under the repository or place the fixture alongside the test output. -
Any runtime/image or Compose behavior change requires the disposable Compose recipe in
skills/compose-disposable-recipe/SKILL.md. Keep hardware-only validation open unless NVIDIA, AMD, or Intel hardware is actually exercised. A successful CPU fallback test does not prove GPU execution. -
Record unique tags for the locally built CUDA Agent and any Central/helper fixture image before building. Install an EXIT trap before the build/start; after stopping the project, remove each exact local tag independently and verify it is absent, including after failed builds/assertions. Preserve the test exit status and report cleanup errors. Retain shared CUDA/runtime base layers; never use
--rmi allordocker image prune. -
The current pinned GPU image pairs ONNX Runtime 1.22 with NVIDIA CUDA 12.8.1/cuDNN 9.8.0.87 on amd64. The CUDA runtime base is pinned by the architecture-specific manifest digest in
docker/Dockerfile.agent.gpu; the dev overlay targetslinux/amd64and the Dockerfile uses that target rather than a constantFROM --platformoverride. Refresh the digest only after checking the ONNX Runtime compatibility table and obtaining the matching NVIDIA registry digest.
Current limitation
The optional GPU image, signed manifest publication, installer selection, and Docker auto-update variant are implemented. On 5 November 2026, the post-fix GPU image built from this source with locked GPU restore. Rendered Compose confirmed CPU has no NVIDIA device requirement and the opt-in overlay selects the GPU image. A local disposable runtime check launched the GPU image without NVIDIA devices on an isolated network and tmpfs state: logs confirmed no GPU detection, fallback to CPUExecutionProvider, and YOLO model initialization; a synthetic HTTP Central mock accepted registration and heartbeat (200/204), and /healthz returned 200. The repository RealOnnx_CpuModel_ProcessesFullHdImage test passed 1/1 with HeimdallOnnxRuntime=GPU. The mock did not implement configuration/jobs, so no camera frame traversed the Agent/Central loop; a synthetic frame and persisted inference observation remain open. The exact acceptance image tag and container were removed and verified absent; tmpfs, mock listener, and temporary state were gone. The earlier disposable Central/PostgreSQL bootstrap also passed. Physical CUDA execution still requires NVIDIA hardware.
Additional full-loop acceptance attempt, 5 November 2026: disposable Compose project hmgpu-loop-929b670e rendered with CUDA package selection, no NVIDIA reservation, and empty Sentry DSN. Central and the Agent GPU image were built from this checkout under heimdall:hmgpu-loop-929b670e-central and heimdall-agent:hmgpu-loop-929b670e-gpu (GPU image inspected at 3.56 GB). The Compose/Buildx client remained waiting after image export and before any service/container was created, so no Central bootstrap, Agent health, camera configuration, job, frame processing, or database observation was exercised. After stopping only that build handle, cleanup verified 0 containers/0 volumes/0 networks, both exact image tags absent, and the temporary directory absent. docker buildx ls and docker ps responded afterward; this does not establish successful runtime acceptance. Keep the frame-through-job-loop evidence open. An earlier duplicate-target attempt (hmgpu-loop-e9377c0b) was also cleaned with 0/0/0 and both exact image tags absent.