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: several GPUs without typing - a table of the cards, the choice asked, "not supported" said plainly

Niko1221548007f8743f
diff --git a/README.md b/README.md
index f8234adbc..803e76056 100644
--- a/README.md
+++ b/README.md
@@ -42,9 +42,12 @@ A card with more VRAM is faster, because more of the model fits on the GPU: an R
Every PC is different: `START-HERE.bat --calibrate` measures a few engine settings on yours and keeps the fastest
(about 5-10 minutes; on the PC above it made the Coder 7% faster).
-**Two or three NVIDIA cards?** `START-HERE.bat --setup --gpus 0,2` splits the model's layers across them (experimental):
-each card keeps the experts of its own layers, and prompts flow through the cards in a pipeline. On an RTX 5080 +
-RTX 3090 it read prompts 18-20% faster than the 5080 alone, with decoding on par. See [docs/MULTI_GPU.md](docs/MULTI_GPU.md).
+**Two or three NVIDIA cards?** Just run `START-HERE.bat`: it lists your cards, says which ones Strata can use, and
+asks whether to share the model across them (recommended when two can). An install made on one card asks once at
+its next start. Or choose yourself: `START-HERE.bat --gpus 0,2` (both, remembered), `--gpus all`, or `--gpu 0` (one
+card, this start only). Each card keeps the experts of its own layers, and prompts flow through the cards in a
+pipeline: on an RTX 5080 + RTX 3090 prompts were read 18-20% faster than on the 5080 alone, decoding on par.
+Every card must be an RTX 30 series or newer with 8 GB or more. See [docs/MULTI_GPU.md](docs/MULTI_GPU.md).
## Which model should I pick?
diff --git a/docs/MULTI_GPU.md b/docs/MULTI_GPU.md
index f39d9982f..5ec3f4f68 100644
--- a/docs/MULTI_GPU.md
+++ b/docs/MULTI_GPU.md
@@ -12,14 +12,41 @@ needed; cards on x4 or x1 slots work, and the PCIe share of each card is probed
## Using it
-At setup time (Windows: `START-HERE.bat`, Linux: `./setup.sh`):
+**Nothing to type.** `START-HERE.bat` (Linux: `./setup.sh`) lists your NVIDIA cards and says for each one whether
+Strata can use it:
```
---gpus 0,2 the cards, as nvidia-smi numbers them; the first is the main one
+ Your NVIDIA GPUs:
+ GPU 0: NVIDIA GeForce RTX 5080, 16 GB VRAM - can be used
+ GPU 1: NVIDIA GeForce RTX 2080 Ti, 22 GB VRAM - not supported - older than the RTX 30 series (compute capability 7.5; Strata needs 8.0 or newer)
+ GPU 2: NVIDIA GeForce RTX 3090, 24 GB VRAM - can be used
+ ...
+ 1) GPU 0 (NVIDIA GeForce RTX 5080, 16 GB) + GPU 2 (NVIDIA GeForce RTX 3090, 24 GB) together (recommended)
+ 2) GPU 2 (NVIDIA GeForce RTX 3090, 24 GB) only
+ 3) GPU 0 (NVIDIA GeForce RTX 5080, 16 GB) only
+Which GPUs? [1]:
+```
+
+When two or more cards can share the model, the two best together are recommended (the newest generation first:
+it becomes the main card). A model installed on one card asks once, at its next start, whether to use both from
+now on; the answer is kept.
+
+**Choosing yourself** (at setup or at any start):
+
+```
+--gpus 0,2 these cards together, as nvidia-smi numbers them; the first is the main one. Remembered.
+--gpus all every card that can share the model
+--gpu 0 one card (at a start: for that start only)
--layer-split auto (default) or the first layer of each later card, e.g. 18 or 16,32
```
-or in an existing config (`strata-*.json`), then restart:
+**Not supported** (setup says so and names the cards that can be used instead):
+- a card older than the RTX 30 series (compute capability below 8.0: RTX 20, GTX 16/10);
+- a card with less than 8 GB of VRAM, together with others (each card holds a copy of the dense weights and its
+ own prompt buffers);
+- AMD and Intel GPUs, and a mix of NVIDIA with them.
+
+Or edit an existing config (`strata-*.json`), then restart:
```json
"gpu": [0, 2],
diff --git a/setup.py b/setup.py
index d1628227b..71644a6a1 100644
--- a/setup.py
+++ b/setup.py
@@ -274,6 +274,161 @@ def gpus():
GPU_PICK = None # --gpu N (issue #51); None: the card with the most VRAM
+SPLIT_MIN_VRAM_GB = 8 # a card sharing a model holds the dense weights and its own
+ # prompt buffers too (docs/MULTI_GPU.md)
+
+
+def cc(g) -> str:
+ return f"{g['arch'][:-1]}.{g['arch'][-1]}"
+
+
+def gpu_problem(g, together=False):
+ """Why Strata cannot use this card, in plain words (None: it can)."""
+ if int(g["arch"]) < 80:
+ return (f"not supported - older than the RTX 30 series (compute capability {cc(g)}; Strata needs 8.0 or "
+ "newer)")
+ if together and g["vram_gb"] < SPLIT_MIN_VRAM_GB - 0.5:
+ return (f"not supported together with other GPUs - {g['vram_gb']:.0f} GB of VRAM (a card sharing the model "
+ f"needs {SPLIT_MIN_VRAM_GB} GB or more)")
+ return None
+
+
+def gpu_rank(g):
+ """The order cards share a model in: the newest generation first (it gets the first layers and most of the
+ work), then the most VRAM."""
+ return (-int(g["arch"]), -round(g["vram_gb"]), g["index"])
+
+
+def gpu_name(g) -> str:
+ return f"GPU {g['index']} ({g['name']}, {g['vram_gb']:.0f} GB)"
+
+
+def gpu_table(found) -> None:
+ say(" Your NVIDIA GPUs:")
+ for g in found:
+ p = gpu_problem(g)
+ say(f" GPU {g['index']}: {g['name']}, {g['vram_gb']:.0f} GB VRAM - " + ("can be used" if p is None else p))
+
+
+def together_ok(found) -> list:
+ """The cards that can share one model, in the order they would (empty if fewer than two)."""
+ ok_ = sorted([g for g in found if gpu_problem(g, together=True) is None], key=gpu_rank)
+ return ok_ if len(ok_) >= 2 else []
+
+
+def parse_gpus(text, found) -> list:
+ """--gpus / --gpu with several: "0,2" or "all" (every card that can share the model)."""
+ if str(text).strip().lower() == "all":
+ sel = [g["index"] for g in together_ok(found)]
+ if not sel:
+ gpu_table(found)
+ fail("--gpus all: this PC does not have two GPUs Strata can use together")
+ return sel
+ try:
+ sel = [int(x) for x in str(text).split(",") if x.strip()]
+ except ValueError:
+ fail(f"--gpus takes GPU numbers as nvidia-smi numbers them, e.g. --gpus 0,2 (or --gpus all), not {text!r}")
+ if len(sel) < 2 or len(set(sel)) != len(sel):
+ fail("--gpus takes two or more different GPUs, e.g. --gpus 0,2 (one GPU: --gpu 0)")
+ return sel
+
+
+def check_gpus(sel, found, what="") -> None:
+ """Stops with a plain message when a chosen card is missing or cannot be used, and says what can."""
+ together = len(sel) > 1
+ for i in sel:
+ g = next((x for x in found if x["index"] == i), None)
+ p = "not found on this PC" if g is None else gpu_problem(g, together)
+ if p is None:
+ continue
+ say()
+ gpu_table(found)
+ can = together_ok(found)
+ single = [x for x in found if gpu_problem(x) is None]
+ hint = ("use them together with --gpus " + ",".join(str(x["index"]) for x in can) if can else
+ "use one GPU with --gpu " + str(single[0]["index"]) if single else
+ "Strata needs an NVIDIA RTX 30 series or newer card")
+ fail(f"GPU {i}{'' if g is None else ' (' + g['name'] + ')'} {what}cannot be used: {p}", hint)
+
+
+def engine_archs():
+ """The GPU generations the installed engine has code for: (archs, ptx), or None when there is none."""
+ info = ROOT / "engine" / "BUILD.json"
+ try:
+ meta = json.loads(info.read_text())
+ except (OSError, ValueError):
+ return None
+ return [int(x) for x in meta.get("archs", [])], bool(meta.get("ptx"))
+
+
+def engine_runs_on(g) -> bool:
+ ea = engine_archs()
+ if ea is None or not ea[0]:
+ return True
+ archs, ptx = ea
+ return int(g["arch"]) in archs or (ptx and int(g["arch"]) > max(archs))
+
+
+def choose_gpus(a, found) -> list:
+ """Which cards this install uses: --gpus / --gpu, or asked when two or more can share the model (the two best
+ together recommended), else the supported card with the most VRAM. Returns their numbers, the main one first."""
+ if a.gpus:
+ sel = parse_gpus(a.gpus, found)
+ check_gpus(sel, found)
+ return sel
+ if a.gpu is not None:
+ check_gpus([a.gpu], found)
+ return [a.gpu]
+ single = sorted([g for g in found if gpu_problem(g) is None], key=lambda x: (-round(x["vram_gb"]), x["index"]))
+ if not single:
+ gpu_table(found)
+ fail("none of your GPUs can run Strata", "it needs an NVIDIA RTX 30 series or newer (compute capability 8.0+)")
+ can = together_ok(found)
+ if not can:
+ return [single[0]["index"]]
+ say()
+ say(f" Strata can run the model on one GPU, or share it across {'these' if len(can) > 2 else 'both'}: then each"
+ " card holds the")
+ say(" experts of its own layers, so together they hold about twice as many, and prompts are read about 20%")
+ say(" faster (details: docs/MULTI_GPU.md). A much slower extra card can also make it slower.")
+ opts = [can[:2]] + ([can] if len(can) > 2 else []) + [[g] for g in single]
+ for i, o in enumerate(opts, 1):
+ label = (" + ".join(gpu_name(g) for g in o) + " together") if len(o) > 1 else gpu_name(o[0]) + " only"
+ say(f" {i}) {label}" + (" (recommended)" if i == 1 else ""))
+ for g in found:
+ if gpu_problem(g, together=True) is not None:
+ say(f" (GPU {g['index']}, {g['name']}: {gpu_problem(g, together=True)})")
+ pick = opts[int(ask("Which GPUs?", [str(i) for i in range(1, len(opts) + 1)], "1", a.yes or a.check)) - 1]
+ return [g["index"] for g in pick]
+
+
+def offer_together(cfg_path: Path, cfg: dict, yes: bool) -> dict:
+ """Starting a model set up for one card on a PC with two or more that can share it: asked once (the answer is
+ saved in its config)."""
+ if isinstance(cfg.get("gpu"), list) or cfg.get("gpus_asked"):
+ return cfg
+ found = gpus()
+ can = together_ok(found)
+ if not can:
+ return cfg
+ pair = can[:2]
+ cfg["gpus_asked"] = True
+ say()
+ say(" This PC has " + " and ".join(gpu_name(g) for g in pair) + ": Strata can share the model across both.")
+ say(" Together they hold about twice the model's experts and read prompts about 20% faster (docs/MULTI_GPU.md).")
+ missing = [g for g in pair if not engine_runs_on(g)]
+ if missing:
+ say(" The installed engine has no code for " + ", ".join(g["name"] for g in missing) + ": to use them "
+ "together, run START-HERE.bat --setup --gpus " + ",".join(str(g["index"]) for g in pair))
+ elif ask(" Use both from now on? (you can change it later: START-HERE.bat --gpu N for one card)",
+ ["y", "n"], "y", yes) == "y":
+ cfg["gpu"] = [g["index"] for g in pair]
+ cfg["layer_split"] = cfg.get("layer_split") or "auto"
+ ok("from now on this model runs on " + " + ".join(gpu_name(g) for g in pair))
+ else:
+ ok("staying on one GPU (START-HERE.bat --gpus " + ",".join(str(g["index"]) for g in pair) + " switches)")
+ cfg_path.write_text(json.dumps(cfg, indent=1), encoding="utf-8")
+ return cfg
def gpu_info(pick=None):
@@ -512,9 +667,11 @@ def get_prebuilt(url_base, gpu, vision, updating=False) -> Path | None:
shutil.rmtree(tmp, ignore_errors=True)
return None
archs = [int(a) for a in meta.get("archs", [])]
- arch = int(gpu["arch"])
- if arch not in archs and not (meta.get("ptx") and arch > max(archs)):
- warn(f"the ready-made engine is built for {', '.join(str(a) for a in archs)}; your GPU is {arch}" + ("" if updating else ": compiling instead"))
+ miss = [int(x) for x in gpu.get("archs", [gpu["arch"]])
+ if int(x) not in archs and not (meta.get("ptx") and int(x) > max(archs))]
+ if miss:
+ warn(f"the ready-made engine is built for {', '.join(str(a) for a in archs)}; your GPU is "
+ f"{', '.join(str(x) for x in miss)}" + ("" if updating else ": compiling instead"))
shutil.rmtree(tmp, ignore_errors=True)
return None
for p in tmp.iterdir():
@@ -568,6 +725,7 @@ def update_installed_engine(url_base) -> None:
try: # a failed compile must not stop the model from starting
if gpu is None:
raise RuntimeError("no NVIDIA GPU found")
+ gpu = {**gpu, "archs": sorted({int(gpu["arch"]), *(int(x) for x in meta.get("archs", []))})}
build_engine(gpu, vision, False, get_llama_cpp())
except (Exception, SystemExit) as e:
warn(f"could not compile the updated engine{'' if isinstance(e, SystemExit) else f' ({e})'}: starting the installed one")
@@ -589,7 +747,7 @@ def update_installed_engine(url_base) -> None:
def install_build_tools(gpu, yes):
"""The compiler and the CUDA toolkit, installed for the user (asks once). Returns (nvcc, vcvars)."""
nvcc, cuda_v = find_nvcc()
- need_cuda = (12, 8) if int(gpu["arch"]) >= 120 else (12, 0)
+ need_cuda = (12, 8) if max(int(x) for x in gpu.get("archs", [gpu["arch"]])) >= 120 else (12, 0)
vcvars = find_vcvars() if WIN else None
have_cc = vcvars is not None if WIN else shutil.which("g++") is not None
missing = []
@@ -701,23 +859,25 @@ def build_engine(gpu, vision, yes, llama) -> Path:
ok("engine already built for this PC")
return eng
nvcc, vcvars = install_build_tools(gpu, yes)
+ archs = sorted({int(x) for x in gpu.get("archs", [gpu["arch"]])}) # every card the model runs on
+ cuda_archs = ";".join(str(x) for x in archs)
if not engine_ok:
say(" The engine's source changed: compiling it again (only what changed, a few minutes) ..."
if local and (eng / EXE).exists() else " Compiling the Strata engine for your GPU (10-20 minutes, once) ...")
cmake_build(ROOT, ROOT / "build", "strata",
- ["-DSTRATA_ENABLE_CUDA=ON", "-DSTRATA_BUILD_TESTS=OFF", f"-DCMAKE_CUDA_ARCHITECTURES={gpu['arch']}",
+ ["-DSTRATA_ENABLE_CUDA=ON", "-DSTRATA_BUILD_TESTS=OFF", f"-DCMAKE_CUDA_ARCHITECTURES={cuda_archs}",
f"-DCMAKE_CUDA_COMPILER={nvcc}", f"-DSTRATA_GGML_DIR={llama}"], vcvars, "build-strata.bat")
shutil.copy2(ROOT / "build" / EXE, eng / EXE)
if not vision_ok:
say(" Compiling the image encoder" + (" with CUDA (10-20 minutes, once) ..." if vision == "gpu" else " ..."))
defs = [f"-DLLAMA_DIR={llama}", f"-DSTRATA_VISION_CUDA={'ON' if vision == 'gpu' else 'OFF'}"]
if vision == "gpu":
- defs += [f"-DCMAKE_CUDA_ARCHITECTURES={gpu['arch']}", f"-DCMAKE_CUDA_COMPILER={nvcc}"]
+ defs += [f"-DCMAKE_CUDA_ARCHITECTURES={cuda_archs}", f"-DCMAKE_CUDA_COMPILER={nvcc}"]
cmake_build(ROOT / "tools" / "vision", ROOT / "build-vision", "strata-vision", defs, vcvars, "build-vision.bat")
shutil.copy2(ROOT / "build-vision" / "bin" / VEXE, eng / VEXE)
bindir = Path(nvcc).parent # the toolkit's own libraries (bin, bin/x64, lib64)
dirs = [str(d) for d in (bindir, bindir / "x64", bindir.parent / "lib64") if d.is_dir()]
- stamp.write_text(json.dumps({"source": "local", "version": source_version(), "archs": [int(gpu["arch"])],
+ stamp.write_text(json.dumps({"source": "local", "version": source_version(), "archs": archs,
"vision": vision,
"cuda_dirs": dirs, "src": src, "vision_src": vsrc if want_vision else None}, indent=1))
ok(f"engine compiled: {eng / EXE}")
@@ -958,7 +1118,9 @@ def is_wsl() -> bool:
def hardware_key(cfg: dict) -> str:
"""What a calibration is valid for: this GPU, CPU and RAM, and the model with its context and images setting
(the context's KV cache and the image encoder take VRAM from the expert cache)."""
- g = gpu_info(cfg.get("gpu")) or {}
+ sel = cfg.get("gpu")
+ gl = [gpu_info(i) or {} for i in sel] if isinstance(sel, list) else [gpu_info(sel) or {}]
+ g = {"name": " + ".join(x.get("name", "?") for x in gl), "vram_gb": sum(x.get("vram_gb", 0) for x in gl)}
a = cfg.get("args", [])
ctx = a[a.index("--max-context") + 1] if "--max-context" in a else "?"
return "|".join([g.get("name", "?"), f"{g.get('vram_gb', 0):.0f}GB", cpu_info()[0], f"{ram_gb():.0f}GB",
@@ -1024,7 +1186,8 @@ def upgrade_config(cfg_path: Path, cfg: dict) -> dict:
return cfg
-def start(cfg_path: Path, port: int | None, gpu: int | list | None = None, open_browser=True) -> int:
+def start(cfg_path: Path, port: int | None, gpu: int | list | None = None, open_browser=True, yes=False,
+ layer_split=None) -> int:
cfg = upgrade_config(cfg_path, json.loads(cfg_path.read_text(encoding="utf-8-sig")))
missing = [p for p in [cfg["exe"], *[a for a in cfg["args"] if a.endswith(".gguf")]] if not Path(p).exists()]
if missing:
@@ -1032,10 +1195,28 @@ def start(cfg_path: Path, port: int | None, gpu: int | list | None = None, open_
cfg_path.touch() # the most recently used model
cmd = [sys.executable, str(ROOT / "serve" / "server.py"), "--engine", "strata", "--config", str(cfg_path),
"--port", str(port or cfg.get("port", 8080))]
- if gpu is not None: # one card, or several (--gpus): the server splits the layers
- for g in (gpu if isinstance(gpu, list) else [gpu]):
- gpu_info(g) # stops with the list of GPUs if there is no such one
- cmd += ["--gpu", ",".join(str(g) for g in gpu) if isinstance(gpu, list) else str(gpu)]
+ found = gpus()
+ if isinstance(gpu, list): # --gpus: saved, this model runs on these cards from now on
+ check_gpus(gpu, found)
+ cfg["gpu"], cfg["gpus_asked"] = gpu, True
+ cfg["layer_split"] = layer_split or cfg.get("layer_split") or "auto"
+ cfg_path.write_text(json.dumps(cfg, indent=1), encoding="utf-8")
+ gpu = None
+ elif gpu is not None: # --gpu N: this start only, on that card
+ check_gpus([gpu], found)
+ cmd += ["--gpu", str(gpu)]
+ else:
+ cfg = offer_together(cfg_path, cfg, yes)
+ use = gpu if gpu is not None else cfg.get("gpu")
+ if isinstance(use, list):
+ check_gpus(use, found, "(chosen for this model) ")
+ byid = {g["index"]: g for g in found}
+ ok("GPUs: " + " + ".join(gpu_name(byid[i]) for i in use) + f" together (layers split {cfg.get('layer_split') or 'auto'})")
+ elif found:
+ g = next((x for x in found if x["index"] == use), None) if use is not None else max(
+ found, key=lambda x: (round(x["vram_gb"]), -x["index"]))
+ if g is not None:
+ ok("GPU: " + gpu_name(g))
if open_browser:
cmd.append("--open")
gb = 0.0
@@ -1085,11 +1266,11 @@ def main() -> int:
help="EXPERIMENTAL, off by default: the control vector in data/experimental-speed-projection "
"(or another GGUF) as a projection on layers 4-44; see docs/DETAILS.md")
ap.add_argument("--port", type=int, help="the server's port (default: the one the install was set up with, 8080 for a new one)")
- ap.add_argument("--gpu", help="the GPU to use, numbered as nvidia-smi numbers them (default: the one with the "
- "most VRAM; with --setup it is saved, when starting it overrides the saved one)")
- ap.add_argument("--gpus", help="several GPUs for one model, as nvidia-smi numbers them (\"0,2\"): the layers are "
- "split across them, the first GPU is the main one (saved with --setup; see "
- "docs/MULTI_GPU.md)")
+ ap.add_argument("--gpu", help="one GPU, numbered as nvidia-smi numbers them (default: asked when several can be "
+ "used; with --setup it is saved, when starting it is for that start only)")
+ ap.add_argument("--gpus", help="several GPUs sharing one model, as nvidia-smi numbers them: \"0,2\", or \"all\" "
+ "(every card that can); the first is the main one. Saved, also when starting "
+ "(see docs/MULTI_GPU.md)")
ap.add_argument("--layer-split", help="with --gpus: where each later GPU's layers start (\"18\", \"16,32\"); "
"default auto, placed from each GPU's free VRAM")
ap.add_argument("--host", help="where the server listens: 127.0.0.1 = this PC only (default), 0.0.0.0 = also other "
@@ -1146,15 +1327,10 @@ def main() -> int:
a.gpu = a.gpu if a.gpu is not None else ch.get("gpu")
a.yes = True
global GPU_PICK
- multi = [int(x) for x in a.gpus.split(",") if x.strip()] if a.gpus else []
- if multi:
- if len(multi) < 2 or len(set(multi)) != len(multi):
- fail("--gpus takes two or more different GPUs, e.g. --gpus 0,2")
- a.gpu = multi[0] # the main GPU: the checks and the sizing below are its
- GPU_PICK = a.gpu
- # starting an installed model: --gpus 0,2 splits it across those cards now (it used to start on the first one
- # alone unless given with --setup), --gpu N runs it on one card; neither: the saved choice
- run_gpu = multi or a.gpu
+ # starting an installed model: --gpus 0,2 (or all) saves those cards for it and starts on them (it used to start
+ # on the first one alone unless given with --setup), --gpu N runs this start on one card; neither: the saved
+ # choice, and asked once when the PC has cards that could share the model
+ run_gpu = (parse_gpus(a.gpus, gpus()) if a.gpus else None) or a.gpu
port = a.port or 8080 # a new install's port (issue #32: --port for an existing one)
if have and a.calibrate and not (a.setup or a.model or a.family or a.check):
if not a.build:
@@ -1166,35 +1342,38 @@ def main() -> int:
say(f" {i}) {json.loads(c.read_text(encoding='utf-8-sig')).get('model_name', c.stem)}")
pick_cfg = have[int(ask("Tune which one?", [str(i) for i in range(1, len(have) + 1)], "1", a.yes)) - 1]
calibrate_config(pick_cfg)
- return 0 if a.no_start else start(pick_cfg, a.port, run_gpu)
+ return 0 if a.no_start else start(pick_cfg, a.port, run_gpu, yes=a.yes, layer_split=a.layer_split)
if have and not (a.setup or a.model or a.family or a.check or a.no_start):
if not a.build:
update_installed_engine(a.prebuilt)
if len(have) == 1:
- return start(have[0], a.port, run_gpu)
+ return start(have[0], a.port, run_gpu, yes=a.yes, layer_split=a.layer_split)
say()
for i, c in enumerate(have, 1):
say(f" {i}) {json.loads(c.read_text(encoding='utf-8-sig')).get('model_name', c.stem)}")
say(f" {len(have) + 1}) install another model / change settings")
pick = int(ask("Which one?", [str(i) for i in range(1, len(have) + 2)], "1", a.yes))
if pick <= len(have):
- return start(have[pick - 1], a.port, run_gpu)
+ return start(have[pick - 1], a.port, run_gpu, yes=a.yes, layer_split=a.layer_split)
# ---- 1. the PC
step(1, "checking your PC")
- gpu = gpu_info()
- if gpu is None:
+ found = gpus()
+ if not found:
fail("no NVIDIA GPU found (nvidia-smi did not answer)",
"install the NVIDIA driver from https://www.nvidia.com/drivers and restart the PC")
- ok(f"GPU: {gpu['name']}, {gpu['vram_gb']:.1f} GB VRAM, compute capability {gpu['arch'][:-1]}.{gpu['arch'][-1]}, "
- f"driver {gpu['driver']}")
- if gpu["count"] > 1:
- say(f" {gpu['count']} NVIDIA GPUs: Strata uses GPU {gpu['index']}"
- + (" (the one with the most VRAM)" if a.gpu is None else "") + " - choose another with --gpu N:")
- for x in gpus():
- say(f" {x['index']}: {x['name']}, {x['vram_gb']:.0f} GB")
- if int(gpu["arch"]) < 80:
- fail("this GPU is older than the RTX 30 series (compute capability 8.0 is required)")
+ if len(found) > 1 or gpu_problem(found[0]) is not None:
+ gpu_table(found)
+ sel = choose_gpus(a, found) # asked when two or more cards can share the model
+ multi = sel if len(sel) > 1 else []
+ a.gpu = sel[0] # the main GPU: the checks and the sizing below are its
+ GPU_PICK = a.gpu
+ gpu = gpu_info(a.gpu)
+ chosen = [gpu_info(i) for i in sel]
+ gpu["archs"] = sorted({x["arch"] for x in chosen}) # the engine needs code for every one of them
+ if multi:
+ ok("GPUs: " + " + ".join(gpu_name(x) for x in chosen) + " together (the model's layers are split across them)")
+ ok(f"GPU: {gpu['name']}, {gpu['vram_gb']:.1f} GB VRAM, compute capability {cc(gpu)}, driver {gpu['driver']}")
if driver_major(gpu) < MIN_DRIVER:
fail(f"the NVIDIA driver is too old ({gpu['driver']}; {MIN_DRIVER} or newer is needed)",
"update it with the NVIDIA App or from https://www.nvidia.com/drivers, restart, and run this again")
@@ -1255,7 +1434,8 @@ def main() -> int:
"choose Q2_0 or IQ2_XS, or add RAM")
ok(f"size: {model}")
tag = fam["tag"] + model # names of the pack, config and start script
- rec_ctx = 32768 if gpu["vram_gb"] < 14 else 65536 if gpu["vram_gb"] < 20 else 131072
+ small = min(x["vram_gb"] for x in chosen) # each card keeps its layers' KV of the whole context
+ rec_ctx = 32768 if small < 14 else 65536 if small < 20 else 131072
if a.context:
ctx = a.context
else:
@@ -1441,11 +1621,8 @@ def main() -> int:
"lib_dirs": lib_dirs, "port": port}
if gpu["count"] > 1 or a.gpu is not None:
cfg["gpu"] = gpu["index"] # the engine is told this card (issue #51)
+ cfg["gpus_asked"] = True # chosen at setup: not asked again at start
if multi: # a layer split across these cards (the server adds the flag)
- for i in multi[1:]:
- x = gpu_info(i)
- if int(x["arch"]) < 80:
- fail(f"GPU {i} ({x['name']}) is older than the RTX 30 series (compute capability 8.0 is required)")
cfg["gpu"] = multi
cfg["layer_split"] = a.layer_split or "auto"
ok(f"layer split across GPUs {multi} ({cfg['layer_split']})")
diff --git a/tools/calibrate.py b/tools/calibrate.py
index a7c5455b6..b237c93bd 100644
--- a/tools/calibrate.py
+++ b/tools/calibrate.py
@@ -119,7 +119,10 @@ def run(cfg: dict, say=print, start_engine=None) -> dict:
tok = ST.Tokenizer(toks, (tpath / "merges.txt").read_text(encoding="utf-8").split("\n"),
json.loads((tpath / "token_type.json").read_text()))
ids_list = [chat_ids(tok, p) for p in PROMPTS]
- return measure(cfg["args"], ids_list, start_engine, say)
+ args = list(cfg["args"])
+ if isinstance(cfg.get("gpu"), list) and "--layer-split" not in args: # several cards: measured as it runs
+ args += ["--layer-split", str(cfg.get("layer_split") or "auto")]
+ return measure(args, ids_list, start_engine, say)
def measure(base_args: list[str], ids_list, start_engine, say=print) -> dict: