Control: the NVIDIA driver version also from /proc/driver/nvidia/version (Fedora has no nvidia-smi without its cuda package); an integrated AMD GPU beside a usable NVIDIA card is not offered
This commit is contained in:
1 parent
a93264877c
commit
254ee2b9cd
4 files changed
+38
No files matched your search
@@ -474,6 +474,12 @@ def _smi_query(field_name: str) -> list[str]:
|
||||
def nvidia_driver_version() -> str | None:
|
||||
"""The NVIDIA driver version nvidia-smi reports (the oldest one when several cards disagree); None when unreadable."""
|
||||
versions = _smi_query("driver_version")
|
||||
if not versions: # Linux without nvidia-smi (Fedora: it is in xorg-x11-drv-nvidia-cuda): the kernel module says
|
||||
try:
|
||||
found = re.search(r"Kernel Module\s+(\d+(?:\.\d+)+)", Path("/proc/driver/nvidia/version").read_text())
|
||||
versions = [found.group(1)] if found else []
|
||||
except OSError:
|
||||
versions = []
|
||||
return min(versions, key=_version_key) if versions else None
|
||||
|
||||
|
||||
|
||||
@@ -309,6 +309,15 @@ class NeverAcquires(unittest.TestCase):
|
||||
with mock.patch.object(ec, "nvidia_driver_version", return_value="580.178.04"):
|
||||
self.assertEqual(ec.resolve(self.root, backend="cuda", runtime="1").root.name, a.name, "the newer-driver build wins")
|
||||
|
||||
def test_the_driver_version_comes_from_the_kernel_module_when_there_is_no_nvidia_smi(self):
|
||||
text = "NVRM version: NVIDIA UNIX x86_64 Kernel Module 580.95.05 Thu Sep 11 2026 GCC version: gcc 15"
|
||||
with mock.patch.object(ec, "_smi_query", return_value=[]), mock.patch.object(Path, "read_text", return_value=text):
|
||||
self.assertEqual(ec.nvidia_driver_version(), "580.95.05")
|
||||
with mock.patch.object(ec, "_smi_query", return_value=["575.57.08", "580.95.05"]):
|
||||
self.assertEqual(ec.nvidia_driver_version(), "575.57.08", "the oldest when cards disagree")
|
||||
with mock.patch.object(ec, "_smi_query", return_value=[]), mock.patch.object(Path, "read_text", side_effect=OSError):
|
||||
self.assertIsNone(ec.nvidia_driver_version())
|
||||
|
||||
def test_the_component_fetcher_refuses_where_acquiring_is_forbidden(self):
|
||||
store = components.ComponentStore(self.root / "store")
|
||||
artifact = components.Artifact(name="engine.tar.gz", url="https://example.invalid/e.tgz",
|
||||
|
||||
@@ -759,6 +759,10 @@ class Strata:
|
||||
amd = []
|
||||
if not amd and shutil.which("rocm-smi"):
|
||||
amd = rocm_smi_gpus()
|
||||
if any(g.get("usable") for g in nv):
|
||||
for g in amd: # a Ryzen's integrated graphics beside an NVIDIA card: the engine runs on the NVIDIA card
|
||||
if g.get("uma") and g.get("usable"):
|
||||
g["usable"], g["problem"] = False, "integrated graphics: Strata uses the NVIDIA card in this computer"
|
||||
hw["gpus"] = nv + amd
|
||||
if WIN:
|
||||
hw["display_adapters"] = windows_video_controllers()
|
||||
|
||||
@@ -692,6 +692,25 @@ class MacCatalog(unittest.TestCase):
|
||||
self.assertIn("unsloth", [f["family"] for f in s.model_table({"ram_gb": 96, "gpus": []})])
|
||||
|
||||
|
||||
class MixedGraphics(unittest.TestCase):
|
||||
def test_an_integrated_amd_gpu_beside_an_nvidia_card_is_not_offered(self):
|
||||
s = M.Strata(HERE.parent)
|
||||
S = s.setup_module()
|
||||
nv = [{"index": 0, "name": "NVIDIA GeForce RTX 5090", "vram_gb": 31.8, "arch": "120", "driver": "580.95"}]
|
||||
igpu = [{"index": 0, "name": "AMD Radeon Graphics", "vram_gb": 0.5, "arch": "gfx1036", "uma": True}]
|
||||
with mock.patch.object(M.sys, "platform", "linux"), mock.patch.object(M, "WIN", False), mock.patch.object(S, "gpus", lambda: [dict(g) for g in nv]), mock.patch.object(S, "gpu_problem", lambda g: None), mock.patch.object(S, "amd_gpus", lambda: [dict(g) for g in igpu]), mock.patch.object(S, "amd_problem", lambda g: None):
|
||||
hw = s._hardware()
|
||||
by = {g["vendor"]: g for g in hw["gpus"]}
|
||||
self.assertTrue(by["nvidia"]["usable"])
|
||||
self.assertFalse(by["amd"]["usable"])
|
||||
self.assertIn("NVIDIA card", by["amd"]["problem"])
|
||||
rec = s.recommend({**hw, "ram_gb": 92.0})
|
||||
self.assertEqual((rec["backend"], rec["gpu"]["name"]), ("cuda", "NVIDIA GeForce RTX 5090"))
|
||||
# with no NVIDIA card the integrated GPU stays what it was
|
||||
with mock.patch.object(M.sys, "platform", "linux"), mock.patch.object(M, "WIN", False), mock.patch.object(S, "gpus", lambda: []), mock.patch.object(S, "amd_gpus", lambda: [dict(g) for g in igpu]), mock.patch.object(S, "amd_problem", lambda g: None):
|
||||
self.assertTrue(s._hardware()["gpus"][0]["usable"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
|
||||
Reference in new issue
Block a user