Terminal: a failed runtime start names the engine log; doctor warns when the render group is missing
- runtime start/restart/verify that fail print the run config's engine log path and its last lines (the line was only 'server_exited') - doctor: on Linux with a SYCL or HIP run config, a /dev/dri/renderD* (and /dev/kfd) the user cannot open is GPU_DEVICE_ACCESS (warning) naming the render group; seen on P1006 where the engine only said 'No device of requested type available'
This commit is contained in:
1 parent
b9c6c65482
commit
322e3fdfb3
3 files changed
+59
No files matched your search
@@ -1069,9 +1069,27 @@ def _runtime(a: argparse.Namespace) -> int:
|
||||
(" config/launch verified" if result.get("launch_attested") else "") +
|
||||
(f" {readiness_label}" if readiness_label else "") +
|
||||
(f" {result['error']}" if result.get("error") else ""))
|
||||
if not result["ok"] and a.runtime_command in ("start", "restart", "verify"):
|
||||
for line in _engine_log_hint(a.profile):
|
||||
print(line, file=sys.stderr)
|
||||
return 0 if result["ok"] else result.get("exit_code", 6)
|
||||
|
||||
|
||||
def _engine_log_hint(profile: str) -> list[str]:
|
||||
"""Where the engine wrote why it stopped, and its last lines: "server_exited" alone names nothing to read."""
|
||||
try:
|
||||
path, _saved, _revision = profiles.resolve(profile)
|
||||
log = profiles.read_run_config(path).get("log")
|
||||
if not isinstance(log, str) or not log:
|
||||
return []
|
||||
text = Path(log).expanduser().read_text(encoding="utf-8", errors="replace")
|
||||
except (ProfileError, OSError, ValueError, KeyError):
|
||||
return []
|
||||
lines = [line.strip() for line in text.splitlines() if line.strip()]
|
||||
tail = lines[-3:]
|
||||
return [f"engine log: {log}"] + [f" {line[:300]}" for line in tail]
|
||||
|
||||
|
||||
def _ops(a: argparse.Namespace) -> int:
|
||||
from strata_control import journal, recipes
|
||||
machine = a.output == "json"
|
||||
|
||||
@@ -9,6 +9,7 @@ import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from importlib import metadata, util
|
||||
from pathlib import Path
|
||||
|
||||
@@ -221,6 +222,9 @@ def inspect(config_path: Path | None, *, profile_id: str | None = None, live: bo
|
||||
if item["status"] in ("missing", "invalid") and item["required"]:
|
||||
report["issues"].append({"code": "COMPONENT_" + item["status"].upper(), "severity": "error",
|
||||
"component": item["name"], "message": item.get("reason") or "required component unavailable"})
|
||||
access = _device_access_issue(cfg.get("backend"))
|
||||
if access:
|
||||
report["issues"].append(access)
|
||||
if live:
|
||||
report["live_gpu_probe"], live_issues = _live_probe(cfg, report["backend"])
|
||||
report["issues"].extend(live_issues)
|
||||
@@ -229,6 +233,22 @@ def inspect(config_path: Path | None, *, profile_id: str | None = None, live: bo
|
||||
return report
|
||||
|
||||
|
||||
def _device_access_issue(backend: str | None, dev_root: str = "/dev") -> dict | None:
|
||||
"""Linux Intel (SYCL) and AMD (HIP) open the card through /dev/dri/renderD* (and /dev/kfd): a user outside the `render`
|
||||
group gets "No device of requested type available" from the engine, which names nothing to fix. None when it is fine,
|
||||
cannot apply (other OS, other backend) or there is no such device node at all."""
|
||||
if backend not in ("sycl", "hip") or not sys.platform.startswith("linux"):
|
||||
return None
|
||||
nodes = sorted(Path(dev_root, "dri").glob("renderD*"))
|
||||
if backend == "hip" and Path(dev_root, "kfd").exists():
|
||||
nodes.append(Path(dev_root, "kfd"))
|
||||
if not nodes or any(os.access(node, os.R_OK | os.W_OK) for node in nodes):
|
||||
return None
|
||||
return {"code": "GPU_DEVICE_ACCESS", "severity": "warning",
|
||||
"message": f"this user cannot open {', '.join(str(n) for n in nodes)}; the {backend} engine will not see the card. "
|
||||
"Add the user to the `render` group (and `video` for some distributions), then log in again"}
|
||||
|
||||
|
||||
def _monitor_component() -> dict:
|
||||
component = {"name": "monitor_tui", "kind": "python_module", "required": False,
|
||||
"expected_version": MONITOR_TEXTUAL_VERSION}
|
||||
|
||||
@@ -117,6 +117,27 @@ class HipPackageForAnotherCard(unittest.TestCase):
|
||||
self.assertEqual(ec.resolve(root, backend="hip").backend, "hip")
|
||||
|
||||
|
||||
class DeviceAccess(unittest.TestCase):
|
||||
def test_a_render_node_the_user_cannot_open_is_named(self):
|
||||
from strata_control import doctor
|
||||
if not sys.platform.startswith("linux"):
|
||||
self.skipTest("Linux device nodes")
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
(Path(d) / "dri").mkdir()
|
||||
node = Path(d) / "dri" / "renderD128"
|
||||
node.write_text("", encoding="utf-8")
|
||||
os.chmod(node, 0)
|
||||
if os.access(node, os.R_OK):
|
||||
self.skipTest("running as a user that can open anything")
|
||||
issue = doctor._device_access_issue("sycl", d)
|
||||
self.assertEqual(issue["code"], "GPU_DEVICE_ACCESS")
|
||||
self.assertIn("render", issue["message"])
|
||||
os.chmod(node, 0o666)
|
||||
self.assertIsNone(doctor._device_access_issue("sycl", d))
|
||||
self.assertIsNone(doctor._device_access_issue("cuda", d))
|
||||
self.assertIsNone(doctor._device_access_issue("hip", tempfile.gettempdir() + "/none"))
|
||||
|
||||
|
||||
class ArchiveContents(unittest.TestCase):
|
||||
def test_the_fingerprint_table_models_import_reads_is_in_the_payload(self):
|
||||
sys.path.insert(0, str(ROOT / "packaging"))
|
||||
|
||||
Reference in new issue
Block a user