Skip to content

armgit / ODS

Public Imported from GitHub
0

ODS V3 Pre-Release: Public testing and refinement ahead of the official V3 launch. Turn your PC, Mac, or Linux box into a private AI server.

fix(dashboard-api): GPU cards list only the services that run on them (#8275)

Mike Bradleyb33bfd1606e2
diff --git a/ods/docker-compose.base.yml b/ods/docker-compose.base.yml
index c5622b6ee..4cb6ef7c5 100644
--- a/ods/docker-compose.base.yml
+++ b/ods/docker-compose.base.yml
@@ -292,6 +292,9 @@ services:
- GPU_BACKEND=${GPU_BACKEND:-nvidia}
- GPU_COUNT=${GPU_COUNT:-1}
- GPU_ASSIGNMENT_JSON_B64=${GPU_ASSIGNMENT_JSON_B64:-}
+ # The GPU page leaves CPU Whisper off its assigned GPU; the same
+ # unreadable-.env fallback as ENABLE_OPEN_WEBUI above.
+ - WHISPER_ACCELERATION=${WHISPER_ACCELERATION:-}
- LLAMA_ARG_SPLIT_MODE=${LLAMA_ARG_SPLIT_MODE:-}
- LLAMA_ARG_TENSOR_SPLIT=${LLAMA_ARG_TENSOR_SPLIT:-}
- HOST_RAM_GB=${HOST_RAM_GB:-0}
diff --git a/ods/extensions/services/dashboard-api/routers/gpu.py b/ods/extensions/services/dashboard-api/routers/gpu.py
index 07e0477e7..0e80ebab1 100644
--- a/ods/extensions/services/dashboard-api/routers/gpu.py
+++ b/ods/extensions/services/dashboard-api/routers/gpu.py
@@ -15,6 +15,7 @@ from fastapi import APIRouter, Depends, HTTPException
from security import verify_api_key
+from helpers import get_cached_services
from gpu import (
aggregate_gpu_details,
decode_gpu_assignment,
@@ -282,6 +283,26 @@ async def gpu_detailed():
return result
+def _drop_services_off_the_gpu(gpus: list[IndividualGPU]) -> None:
+ """Keep a GPU's assigned services only when they run on a GPU here.
+
+ The installer assigns a GPU to every GPU-capable service, enabled or not,
+ and Whisper on the CPU image keeps its assignment. Before the first status
+ poll the assignment is all there is.
+ """
+ statuses = get_cached_services()
+ if statuses is None:
+ return
+ deployed = {status.id for status in statuses if status.status != "not_deployed"}
+ whisper_on_cpu = _live_env_value("WHISPER_ACCELERATION").strip().lower() == "cpu"
+ for gpu in gpus:
+ # Assignment names use underscores (llama_server); service IDs use hyphens.
+ gpu.assigned_services = [
+ name for name in gpu.assigned_services
+ if name.replace("_", "-") in deployed and not (name == "whisper" and whisper_on_cpu)
+ ]
+
+
async def _read_detailed_gpu_status() -> MultiGPUStatus:
"""Discover one complete GPU snapshot without publishing partial results."""
gpu_backend = os.environ.get("GPU_BACKEND", "").lower() or "nvidia"
@@ -295,6 +316,8 @@ async def _read_detailed_gpu_status() -> MultiGPUStatus:
assignment_full = decode_gpu_assignment()
assignment_data = assignment_full.get("gpu_assignment") if assignment_full else None
+ if assignment_full:
+ _drop_services_off_the_gpu(gpus)
return MultiGPUStatus(
gpu_count=len(gpus),
diff --git a/ods/extensions/services/dashboard-api/tests/test_compose_env_mount.py b/ods/extensions/services/dashboard-api/tests/test_compose_env_mount.py
index 7983e3b06..3e8f809bc 100644
--- a/ods/extensions/services/dashboard-api/tests/test_compose_env_mount.py
+++ b/ods/extensions/services/dashboard-api/tests/test_compose_env_mount.py
@@ -26,3 +26,10 @@ def test_dashboard_api_receives_the_offline_update_switch_for_an_unreadable_env(
service = yaml.safe_load(compose.read_text(encoding="utf-8"))["services"]["dashboard-api"]
assert "DISABLE_UPDATE_CHECK=${DISABLE_UPDATE_CHECK:-false}" in service["environment"]
+
+
+def test_dashboard_api_receives_whisper_acceleration_for_an_unreadable_env():
+ compose = Path(__file__).resolve().parents[4] / "docker-compose.base.yml"
+ service = yaml.safe_load(compose.read_text(encoding="utf-8"))["services"]["dashboard-api"]
+
+ assert "WHISPER_ACCELERATION=${WHISPER_ACCELERATION:-}" in service["environment"]
diff --git a/ods/extensions/services/dashboard-api/tests/test_gpu_detailed.py b/ods/extensions/services/dashboard-api/tests/test_gpu_detailed.py
index 4281559aa..ec81e261a 100644
--- a/ods/extensions/services/dashboard-api/tests/test_gpu_detailed.py
+++ b/ods/extensions/services/dashboard-api/tests/test_gpu_detailed.py
@@ -679,3 +679,75 @@ class TestGpuDetailedLiveAssignment:
assert result.split_mode == "layer"
assert result.tensor_split is None
+
+
+def _status(service_id, status):
+ from models import ServiceStatus
+
+ return ServiceStatus(id=service_id, name=service_id, port=1, external_port=1, status=status)
+
+
+class TestGpuDetailedAssignedServices:
+ """Workstation06 (2026-10-27): the GB300 card listed Whisper, ComfyUI and
+ embeddings, none of which ran there. Whisper was off, and on the CPU image."""
+
+ def _cards(self, monkeypatch, tmp_path, statuses, env="", assignment=True, environ=None):
+ import routers.gpu as gpu_mod
+ from models import IndividualGPU
+
+ if env is None:
+ (tmp_path / ".env").mkdir() # reading it raises, as an owner-only .env does
+ else:
+ (tmp_path / ".env").write_text(env, encoding="utf-8")
+ monkeypatch.setenv("ODS_INSTALL_DIR", str(tmp_path))
+ monkeypatch.setenv("GPU_BACKEND", "nvidia")
+ monkeypatch.delenv("WHISPER_ACCELERATION", raising=False)
+ for key, value in (environ or {}).items():
+ monkeypatch.setenv(key, value)
+ plan = {"gpu_assignment": {"strategy": "colocated", "services": {}}} if assignment else None
+ monkeypatch.setattr(gpu_mod, "decode_gpu_assignment", lambda: plan)
+ monkeypatch.setattr(gpu_mod, "get_cached_services", lambda: statuses)
+
+ def card(index, services):
+ return IndividualGPU(index=index, uuid=f"GPU-{index}", name=f"GPU {index}", memory_used_mb=1,
+ memory_total_mb=2, memory_percent=50.0, utilization_percent=0,
+ temperature_c=40, assigned_services=services)
+
+ monkeypatch.setattr(gpu_mod, "_get_raw_gpus", lambda _backend: [
+ card(0, ["llama_server"]),
+ card(1, ["whisper", "comfyui", "embeddings", "llama_server"]),
+ ])
+ gpu_mod._detailed_cache["expires"] = 0.0
+ gpu_mod._detailed_cache["value"] = None
+ try:
+ result = asyncio.run(gpu_mod.gpu_detailed())
+ finally:
+ gpu_mod._detailed_cache["expires"] = 0.0
+ gpu_mod._detailed_cache["value"] = None
+ return [gpu.assigned_services for gpu in result.gpus]
+
+ def test_services_the_stack_does_not_run_leave_the_card(self, monkeypatch, tmp_path):
+ statuses = [_status("llama-server", "healthy"), _status("open-webui", "not_deployed")]
+ assert self._cards(monkeypatch, tmp_path, statuses) == [["llama_server"], ["llama_server"]]
+
+ def test_cpu_whisper_leaves_the_card(self, monkeypatch, tmp_path):
+ statuses = [_status(s, "healthy") for s in ("llama-server", "whisper", "comfyui")]
+ cards = self._cards(monkeypatch, tmp_path, statuses, env="WHISPER_ACCELERATION=cpu\n")
+ assert cards[1] == ["comfyui", "llama_server"]
+
+ def test_cpu_whisper_is_read_from_compose_when_the_env_file_is_unreadable(self, monkeypatch, tmp_path):
+ statuses = [_status(s, "healthy") for s in ("llama-server", "whisper")]
+ cards = self._cards(monkeypatch, tmp_path, statuses, env=None, environ={"WHISPER_ACCELERATION": "cpu"})
+ assert cards[1] == ["llama_server"]
+
+ def test_a_deployed_service_that_is_down_stays(self, monkeypatch, tmp_path):
+ statuses = [_status("llama-server", "healthy"), _status("comfyui", "down")]
+ assert self._cards(monkeypatch, tmp_path, statuses)[1] == ["comfyui", "llama_server"]
+
+ def test_before_the_first_status_poll_the_assignment_shows(self, monkeypatch, tmp_path):
+ cards = self._cards(monkeypatch, tmp_path, None)
+ assert cards[1] == ["whisper", "comfyui", "embeddings", "llama_server"]
+
+ def test_services_inferred_from_gpu_processes_are_kept(self, monkeypatch, tmp_path):
+ cards = self._cards(monkeypatch, tmp_path, [], assignment=False)
+ assert cards[1] == ["whisper", "comfyui", "embeddings", "llama_server"]