fix(compose): reserve a GPU only where the daemon has one

A device reservation is not conditional in compose, and a count of 0 does not disable it: the daemon still selects the nvidia driver and fails where there is none. Every GPU-less host therefore lost compose up with 'could not select device driver', which is what broke test-dns on all five CI distros.

Move the reservation out of compose.yml and i18n/compose.override.yml into compose/gpu.override.yml, layered by compose_file_args() only when Profile.gpu_reservable() sees a non-zero INFINITO_GPU_COUNT. A GPU host renders exactly what it rendered before, so the passthrough sys-svc-container needs to find /dev/nvidia0 and emit runtime: nvidia for a gpu:true service stays intact.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5 committed 2026-09-25 09:47:50 +02:00
1 parent 9412762573
commit 4d09286d8b
5 files changed
+30 -14

No files matched your search

@@ -25,6 +25,8 @@ def compose_file_args() -> list[str]:
out += ["-f", "compose/cache.override.yml"]
if profile.shared_cache_network():
out += ["-f", "compose/cache.shared.override.yml"]
if profile.gpu_reservable():
out += ["-f", "compose/gpu.override.yml"]
if (os.environ.get("INFINITO_PUBLISH_PORTS") or "").strip().lower() == "false":
out += ["-f", "compose/noports.override.yml"]
out += ["-f", "i18n/compose.override.yml"]
@@ -35,6 +35,10 @@ class Profile:
declared = _declared("INFINITO_CACHE_STACK")
return (not self.is_ci()) if declared is None else declared
def gpu_reservable(self) -> bool:
"""True iff the docker daemon registers an NVIDIA runtime."""
return (os.environ.get("INFINITO_GPU_COUNT") or "0").strip() not in ("", "0")
def image_mirror_enabled(self) -> bool:
"""True iff image references should be rewritten to the GHCR mirror."""
return self.runs_on_github()
-7
View File
@@ -61,13 +61,6 @@ services:
mem_limit: ${INFINITO_MEM_LIMIT:?Run 'make dotenv' to generate the .env single source of truth}
memswap_limit: ${INFINITO_MEMSWAP_LIMIT:?Run 'make dotenv' to generate the .env single source of truth}
cpus: ${INFINITO_CPUS:?Run 'make dotenv' to generate the .env single source of truth}
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: ${INFINITO_GPU_COUNT:?Run 'make dotenv' to generate the .env single source of truth}
capabilities: [gpu]
<<: *ci_defaults
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
+24
View File
@@ -0,0 +1,24 @@
---
# Layered on compose.yml by the dev tooling when the docker daemon registers an
# NVIDIA runtime. A count of 0 does not disable the reservation, the daemon still
# selects the driver and fails where there is none, so a GPU-less host must not
# carry this file at all.
services:
infinito:
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: ${INFINITO_GPU_COUNT:?Run 'make dotenv' to generate the .env single source of truth}
capabilities: [gpu]
i18n:
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: ${INFINITO_GPU_COUNT:?Run 'make dotenv' to generate the .env single source of truth}
capabilities: [gpu]
-7
View File
@@ -44,13 +44,6 @@ services:
- "${INFINITO_BIND_IP:?Run 'make dotenv' to generate the .env single source of truth}:${INFINITO_I18N_LIBRETRANSLATE_PORT:?Run 'make dotenv' to generate the
.env single source of truth}:${INFINITO_I18N_LIBRETRANSLATE_PORT:?Run 'make dotenv' to generate the .env single source of truth}"
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: ${INFINITO_GPU_COUNT:?Run 'make dotenv' to generate the .env single source of truth}
capabilities: [gpu]
networks:
default:
volumes: