Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

setup: an engine update compiles for the cards the installed models use, not the biggest one (#1485)

Niko1221224bb6f8995b
diff --git a/setup.py b/setup.py
index 0c8a819af..ef295fb8d 100644
--- a/setup.py
+++ b/setup.py
@@ -2910,6 +2910,30 @@ def get_prebuilt(url_base, gpu, vision, updating=False, toolkit=13) -> Path | No
return eng
+def update_engine_gpu(toolkit=13):
+ """#1485: the card an engine update is for. Not simply the one with the most VRAM: a Tesla V100 (32 GB) beside two
+ RTX 4090s was taken, and CUDA 13 cannot compile for it. The cards the installed models are set up for come
+ first (their "gpu"); for the CUDA 13 engine a card it cannot compile for is left out when another can. An
+ explicit --gpu (GPU_PICK) still wins. None when there is no NVIDIA GPU."""
+ if GPU_PICK is not None:
+ return gpu_info()
+ found = gpus()
+ if not found:
+ return None
+ named = set()
+ for c in installed_configs():
+ try:
+ g = json.loads(c.read_text(encoding="utf-8-sig")).get("gpu")
+ except (OSError, ValueError):
+ continue
+ named.update(i for i in (g if isinstance(g, list) else [g]) if isinstance(i, int) and not isinstance(i, bool))
+ pool = [g for g in found if g["index"] in named] or found
+ if int(toolkit) != 12:
+ pool = [g for g in pool if int(g["arch"]) >= CUDA13_MIN_ARCH] or pool
+ g = max(pool, key=lambda x: (round(x["vram_gb"]), -x["index"]))
+ return {**g, "count": len(found)}
+
+
def update_installed_engine(url_base, toolkit=None) -> None:
"""An installed ready-made engine older than MIN_ENGINE is replaced before the model starts, so a plain
START-HERE.bat on an existing install picks up a new release. If that cannot happen (no internet, the model
@@ -2972,7 +2996,7 @@ def update_installed_engine(url_base, toolkit=None) -> None:
except OSError:
warn(f"engine {meta.get('version') or ''} is in use: close the model window and run this again to update it")
return
- gpu = gpu_info()
+ gpu = update_engine_gpu(toolkit)
if local:
try: # a failed compile must not stop the model from starting
if gpu is None:
diff --git a/tools/test_setup_update_gpu.py b/tools/test_setup_update_gpu.py
new file mode 100644
index 000000000..52a753924
--- /dev/null
+++ b/tools/test_setup_update_gpu.py
@@ -0,0 +1,53 @@
+"""#1485: the card an engine update compiles for is one the installed models use (and CUDA 13 can compile for), not
+the card with the most VRAM - a Tesla V100 beside two RTX 4090s made ./update.sh build for sm_70 with CUDA 13.
+
+ python -m unittest tools.test_setup_update_gpu -v
+"""
+import json
+import sys
+import tempfile
+import unittest
+from pathlib import Path
+from unittest import mock
+
+sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
+import setup # noqa: E402
+
+V100 = {"index": 1, "name": "Tesla V100-PCIE-32GB", "vram_gb": 32.0, "arch": "70", "driver": "580"}
+R4090 = lambda i: {"index": i, "name": "RTX 4090", "vram_gb": 24.0, "arch": "89", "driver": "580"} # noqa: E731
+
+
+class UpdateEngineGpu(unittest.TestCase):
+ def pick(self, found, configs, toolkit=13, pinned=None):
+ tmp = tempfile.TemporaryDirectory()
+ self.addCleanup(tmp.cleanup)
+ paths = []
+ for n, cfg in enumerate(configs):
+ p = Path(tmp.name) / f"strata-{n}.json"
+ p.write_text(json.dumps(cfg))
+ paths.append(p)
+ with mock.patch.object(setup, "gpus", return_value=found), \
+ mock.patch.object(setup, "installed_configs", return_value=paths), \
+ mock.patch.object(setup, "GPU_PICK", pinned):
+ return setup.update_engine_gpu(toolkit)
+
+ def test_the_models_cards_not_the_biggest_one(self):
+ g = self.pick([R4090(0), V100, R4090(2)], [{"exe": "x", "args": [], "gpu": [0, 2]}])
+ self.assertEqual(g["arch"], "89")
+ self.assertEqual(g["count"], 3)
+
+ def test_a_card_cuda_13_cannot_compile_for_is_left_out_without_a_config(self):
+ self.assertEqual(self.pick([R4090(0), V100], [])["index"], 0)
+
+ def test_the_cuda_12_engine_may_take_the_volta(self):
+ self.assertEqual(self.pick([R4090(0), V100], [], toolkit=12)["index"], 1)
+
+ def test_only_a_volta_is_still_taken(self):
+ self.assertEqual(self.pick([V100], [])["index"], 1)
+
+ def test_no_nvidia_card(self):
+ self.assertIsNone(self.pick([], []))
+
+
+if __name__ == "__main__":
+ unittest.main()