When the GPU reader did not start for any other reason, the summary says pictures are read on the processor

The reader falls back to the processor for every start failure (4571cf652), but only a full card had words for the person. Any other reason (a kernel-image error, a busy card, the reader's own ERR) left only the server's log line, and a person whose pictures quietly became slow was not told. Vision.cpu_note now also carries, for those causes: "Pictures are read on the processor, which is slower: the picture reader could not start on graphics card N. The reason is in the engine's log: <path>." (without the card on a Mac, or when the number is unknown; without the second sentence when there is no log). Same place as the full-card sentence: /metrics engine.vision_note and the Terminal's launch summary (level warn).
This commit is contained in:
Niko1221 committed 2026-11-10 16:16:55 +01:00
1 parent 7e8206b501
commit dbb2d168cf
4 files changed
+52 -6

No files matched your search

+15 -5
View File
@@ -3356,8 +3356,7 @@ class Vision:
raise
why = " ".join(str(e).split())[:240]
again = " until it is idle" if getattr(self, "elastic", False) else ""
if isinstance(e, VisionNoRoom):
self.cpu_note = self.no_room_note(e.room)
self.cpu_note = self.no_room_note(e.room) if isinstance(e, VisionNoRoom) else self.not_started_note()
print(f"[strata] the GPU picture reader did not start ({why}); pictures are read on the CPU{again}", flush=True)
self.spawn, self.fallback, self.on_cpu = fallback, None, True
self._start_reader()
@@ -3365,13 +3364,24 @@ class Vision:
def no_room_note(self, room) -> str:
"""The sentence for the person when the card had no room for the reader and the processor reads instead: which card (as nvidia-smi numbers it), what
the reader needed, what is free now that it is gone."""
args, _log, env = self.spawn
amd = "hip" in Path(str(args[0])).name.lower()
visible = (env if env is not None else os.environ).get("HIP_VISIBLE_DEVICES" if amd else "CUDA_VISIBLE_DEVICES")
amd, visible = self.visible_cards()
card = reader_room.physical_card(room.device, visible)
need = reader_room.whole_need_mib(room.need_mib, getattr(self, "max_tokens", None)) # the reader's whole need at its limit, not the one allocation that failed
return reader_room.on_processor(card, need, card_free_mib(card, amd) if card is not None else None)
def not_started_note(self) -> str:
"""The sentence for the person when the GPU reader did not start for any other reason and the processor reads instead: the card it would have used
(the first one it is shown), and where the reason is (the engine log, which is the reader's stderr)."""
_amd, visible = self.visible_cards()
card = None if sys.platform == "darwin" else reader_room.physical_card(0, visible) # a Mac has no numbered cards
return reader_room.not_started_on_processor(card, getattr(self.spawn[1], "name", None))
def visible_cards(self):
"""(is it the AMD reader, the cards its environment shows it: CUDA_VISIBLE_DEVICES / HIP_VISIBLE_DEVICES or None)."""
args, _log, env = self.spawn
amd = "hip" in Path(str(args[0])).name.lower()
return amd, (env if env is not None else os.environ).get("HIP_VISIBLE_DEVICES" if amd else "CUDA_VISIBLE_DEVICES")
def use_cpu(self) -> bool:
"""The next start is the CPU reader's (the card has no room for the GPU one): False when there is no CPU reader to use."""
if self.fallback is None:
+19 -1
View File
@@ -151,8 +151,26 @@ class Fallback(unittest.TestCase):
error, said = self.start(v)
self.assertIsNone(error)
self.assertTrue(v.on_cpu)
self.assertIsNone(v.cpu_note)
self.assertIn("ERR cannot load the vision encoder", said)
self.assertEqual(v.cpu_note, "Pictures are read on the processor, which is slower: the picture reader could not start on graphics card 0. "
"The reason is in the engine's log: " + self.logs[0].name + ".")
def test_the_card_in_that_sentence_is_the_first_one_the_reader_is_shown(self):
v = self.vision("""
print("ERR cannot load the vision encoder x.gguf", flush=True)
sys.exit(1)
""", self.READY, env={"CUDA_VISIBLE_DEVICES": "3,1"})
self.start(v)
self.assertIn("could not start on graphics card 3. The reason", v.cpu_note)
def test_on_a_mac_there_is_no_card_number(self):
v = self.vision("""
print("ERR cannot load the vision encoder x.gguf", flush=True)
sys.exit(1)
""", self.READY)
with mock.patch.object(server.sys, "platform", "darwin"):
self.start(v)
self.assertTrue(v.cpu_note.startswith("Pictures are read on the processor, which is slower: the picture reader could not start. The reason is in"))
def test_the_cpu_reader_failing_too_ends_it_with_its_own_error(self):
v = self.vision(self.OOM, """
+8
View File
@@ -113,6 +113,14 @@ def on_processor(card: int | None = None, need_mib: float | None = None, free_mi
"To read them on the card, close the other programs that use it and start again.")
def not_started_on_processor(card: int | None = None, log_path: str | None = None) -> str:
"""The launch goes on and the pictures are read on the processor because the GPU reader did not start for a reason that is not a full card (the summary
line; the reason is in the engine log, which is the reader's stderr). Without the card's number, or the log's path, those words are left out."""
where = f" on graphics card {card}" if card is not None else ""
why = f" The reason is in the engine's log: {log_path}." if log_path else ""
return f"Pictures are read on the processor, which is slower: the picture reader could not start{where}.{why}"
def could_not_start(card: int | None = None, need_mib: float | None = None, free_mib: float | None = None) -> tuple[str, str]:
"""(what happened, the next step) when the launch ends because the reader could not start."""
return (f"The picture reader could not start: {_card(card)} has no room for it{_facts(need_mib, free_mib)}.",
+10
View File
@@ -107,6 +107,16 @@ class Words(unittest.TestCase):
"The picture reader could not start: the graphics card has no room for it (it needs about 0.8 GB; 0.1 GB are free).")
self.assertIn("the graphics card has no room for the picture reader.", reader_room.on_processor(None))
def test_the_summary_line_for_any_other_reason(self):
self.assertEqual(reader_room.not_started_on_processor(0, "/home/u/engine.log"),
"Pictures are read on the processor, which is slower: the picture reader could not start on graphics card 0. "
"The reason is in the engine's log: /home/u/engine.log.")
self.assertEqual(reader_room.not_started_on_processor(None, "/home/u/engine.log"),
"Pictures are read on the processor, which is slower: the picture reader could not start. The reason is in the engine's log: /home/u/engine.log.")
self.assertEqual(reader_room.not_started_on_processor(2, None),
"Pictures are read on the processor, which is slower: the picture reader could not start on graphics card 2.")
self.assertEqual(reader_room.not_started_on_processor(), "Pictures are read on the processor, which is slower: the picture reader could not start.")
def test_a_card_with_next_to_nothing_free_is_not_called_a_tenth(self):
self.assertIn("(less than 0.1 GB are free)", reader_room.on_processor(0, None, 10))
self.assertIn("(less than 0.1 GB are free)", reader_room.on_processor(0, None, 0))