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: the page-file warning advises a fixed size, and says why when Windows is set to grow the file

sergiywithc396dc9c3941
diff --git a/docs/AI_SETUP.md b/docs/AI_SETUP.md
index 3eb9dfcf1..43325358f 100644
--- a/docs/AI_SETUP.md
+++ b/docs/AI_SETUP.md
@@ -185,7 +185,7 @@ line when it is ready; the engine log is `strata-<model>.log` in the Strata fold
| Download or install stopped | Rerun the same setup command; it continues. |
| `port 8080 is already in use` | Strata is already running (check `/health`), or use `--port 8081`. |
| Very slow, disk busy, or "the engine stopped unexpectedly" | Not enough free RAM: close programs, or set up a smaller size (`--setup --model Q2_0` or IQ2_XS). |
-| `ExpertCache: cudaMalloc(...) failed: out of memory` with free VRAM (Windows) | The page file is off or tiny: set it to "System managed" and restart. |
+| `ExpertCache: cudaMalloc(...) failed: out of memory` with free VRAM (Windows) | The page file is off or tiny: set a fixed size (Custom size, the same initial and maximum size, e.g. 65536 MB) and restart; a page file Windows grows on demand ("System managed") may not grow in time (#60). |
| `prompt ... exceeds the context` | Rerun setup with `--setup --context <bigger>`. |
| No AMD GPU found (Linux) | The amdgpu driver lists no GPU; check the card and driver. Integrated GPUs are not supported. |
| Python or build tools could not be installed | Install what the message names (links are printed), then rerun. |
diff --git a/docs/DETAILS.md b/docs/DETAILS.md
index f06f139a4..b93cf3925 100644
--- a/docs/DETAILS.md
+++ b/docs/DETAILS.md
@@ -1655,7 +1655,7 @@ the document, +0.4% on the chat. Details: `bench/results/2026-09-27-esp/`.
| Python or the build tools could not be installed | Install what it names (links are printed), then run it again. Everything already done is kept. |
| `port 8080 is already in use` | Strata is already running (look for its window), or another program uses the port: `START-HERE.bat --port 8081`. |
| `cudaHostRegister ... out of memory` in the log | Normal on Windows: the engine pins the experts in per-layer slices instead. Only a problem if the load then fails. |
-| `ExpertCache: cudaMalloc(...) failed: out of memory` although VRAM is free | Windows' page file is off or tiny: every allocation on the graphics card is also charged to Windows' commit (RAM + page file). Set the page file to "System managed" (System > About > Advanced system settings > Performance > Advanced > Virtual memory) and restart. Since 0.1.19 the engine retries with a smaller cache instead of stopping, and setup warns about a page file under 4 GB (issue #60). |
+| `ExpertCache: cudaMalloc(...) failed: out of memory` although VRAM is free | Windows' page file is off or tiny: every allocation on the graphics card is also charged to Windows' commit (RAM + page file). Set a fixed page file size, the same initial and maximum size (e.g. 65536 MB: System > About > Advanced system settings > Performance > Advanced > Virtual memory > Custom size), and restart: a page file Windows grows on demand ("System managed", or an initial size below the maximum) may not grow in time while the card's memory is charged (#60: "System managed" and 4096-32768 MB still failed, a fixed 64 GB worked). Since 0.1.19 the engine retries with a smaller cache instead of stopping, and setup warns about a page file under 4 GB (issue #60). |
| The first start takes minutes | It is reading 34-55 GB into RAM; the second start is faster while the files are in the OS cache. |
| The PC freezes for a few minutes at the start | Normal, most of all the first time (the server window says when it happens): the engine loads the experts into RAM, pins part of it for the GPU and sizes the expert cache. Wait; don't close the window. Still frozen after 10 minutes: restart the PC, close other programs, try again, or pick a smaller size. |
| `the engine stopped unexpectedly (exit code ...)` | The engine process ended mid-answer - usually out of RAM (Linux ends the biggest program: `sudo dmesg \| grep -i -E 'killed process\|out of memory'`). The next request starts it again by itself. If it repeats: close other programs or pick a smaller size. The server also warns at start when the model's experts leave less than ~6 GB of RAM for everything else. |
diff --git a/setup.py b/setup.py
index 0d6cc4b34..213a3558e 100644
--- a/setup.py
+++ b/setup.py
@@ -428,14 +428,120 @@ def ram_gb():
return 0.0
+_MM_KEY = r"SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management"
+
+
+def _mm_multi_sz(name):
+ """A REG_MULTI_SZ value of Memory Management, None when it cannot be read. PagingFiles is what the Virtual memory
+ dialog set; ExistingPageFiles is where the page files are now."""
+ try:
+ import winreg
+ with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, _MM_KEY) as k:
+ v, _t = winreg.QueryValueEx(k, name)
+ except (ImportError, OSError):
+ return None
+ return [x for x in v if x] if isinstance(v, list) else None
+
+
+def parse_paging_file(line: str):
+ """One PagingFiles entry ("C:\\pagefile.sys 16000 64000", "C:\\pagefile.sys 0 0", "?:\\pagefile.sys"): (drive,
+ initial MB, maximum MB), both -1 when Windows manages the size and the drive '?' when it manages every drive;
+ None for anything else."""
+ s = line.strip()
+ if len(s) < 2 or s[1] != ":":
+ return None
+ parts = s.split()
+ try:
+ initial, maximum = (int(parts[1]), int(parts[2])) if len(parts) >= 3 else (-1, -1)
+ except ValueError:
+ initial, maximum = -1, -1
+ if maximum <= 0:
+ initial, maximum = -1, -1
+ return s[0].upper(), initial, maximum
+
+
+PAGE_FILE_FIXED_MB = 65536 # the advice: a fixed size (initial = maximum) of 64 GB, the size #60's PC started with
+
+
+def _drive_mb(drive: str):
+ """(free MB, the page file's size now in MB) of a drive, None when it cannot be read. The page file is locked:
+ its size comes from the directory entry."""
+ root = f"{drive}:\\"
+ try:
+ du = shutil.disk_usage(root)
+ except OSError:
+ return None
+ current = 0
+ try:
+ with os.scandir(root) as it:
+ for e in it:
+ if e.name.lower() == "pagefile.sys":
+ current = e.stat(follow_symlinks=False).st_size
+ break
+ except OSError:
+ pass
+ return du.free / 2**20, current / 2**20
+
+
+def page_file_setting():
+ """The page files Windows is set to use (PagingFiles, what the Virtual memory dialog writes): [(drive, initial MB,
+ maximum MB, MB now, the drive's free MB)], the sizes -1 for a system-managed file; "?:" (every drive automatic) is
+ the drive ExistingPageFiles names. None off Windows or when the setting cannot be read."""
+ if not WIN:
+ return None
+ lines = _mm_multi_sz("PagingFiles")
+ if lines is None:
+ return None
+ auto = [] # "?:\pagefile.sys": where Windows keeps it now, else C:
+ for s in _mm_multi_sz("ExistingPageFiles") or []:
+ i = s.find(":")
+ if i > 0:
+ auto.append(s[i - 1].upper())
+ auto = auto or [(os.environ.get("SystemDrive") or "C:")[0].upper()]
+ files = []
+ for line in lines:
+ e = parse_paging_file(line)
+ if e is None:
+ continue
+ drive, initial, maximum = e
+ for d in (auto if drive == "?" else [drive]):
+ free, now = _drive_mb(d) or (0.0, 0.0)
+ files.append((d, initial, maximum, now, free))
+ return files
+
+
+def page_file_grows(files) -> bool:
+ """Whether Windows grows one of these page files on demand: system-managed, or an initial size below the maximum."""
+ return any(maximum <= 0 or initial < maximum for _d, initial, maximum, _now, _free in files or [])
+
+
def page_file_gb():
- """The page file's current size (GB) on Windows, None elsewhere. The graphics card's memory needs room there
- too: under Windows' driver model every allocation on the card is also charged to the commit (RAM + page file),
- so with the page file off or tiny the engine cannot use the free VRAM (issue #60)."""
+ """The page files' size (GB) that is there for sure on Windows, None elsewhere. The graphics card's memory needs
+ room there too: under Windows' driver model every allocation on the card is also charged to the commit (RAM + page
+ file), so with the page file off or tiny the engine cannot use the free VRAM (issue #60). What counts is the size
+ the files have now (the commit limit minus RAM), or a file's configured initial size when that is larger (within
+ its drive's free space) - never what a file may grow to: a page file Windows grows on demand may not grow in time
+ while the card's memory is charged (#60: "System managed" and 4096-32768 MB still failed, a fixed 64 GB worked)."""
if not WIN:
return None
m = _memory_status()
- return max(0.0, (m.ullTotalPageFile - m.ullTotalPhys) / 2**30)
+ mb = max(0.0, (m.ullTotalPageFile - m.ullTotalPhys) / 2**20)
+ files = page_file_setting()
+ if files:
+ mb = max(mb, sum(max(now, min(max(initial, 0), now + free)) for _d, initial, _m, now, free in files))
+ return mb / 1024
+
+
+def page_file_advice(pf: float, files) -> str:
+ """Step 1's warning for a page file below 4 GB (issue #60): a fixed size, and why when the setting (`files`,
+ page_file_setting) has Windows grow it on demand."""
+ grows = ("It is set to grow on demand (\"System managed\" or an initial size below the maximum), and a growing "
+ "page file may not grow in time for the card's memory (#60: \"System managed\" and 4096-32768 MB still "
+ "failed, a fixed 64 GB worked). ") if page_file_grows(files) else ""
+ return (f"Windows' page file is {pf:.1f} GB: the graphics card's memory needs room there too (issue #60), so the "
+ f"model may not start or may use less VRAM. {grows}Set a fixed size: System > About > Advanced system "
+ "settings > Performance > Advanced > Virtual memory > Change, untick \"Automatically manage\", Custom size "
+ f"with initial and maximum size {PAGE_FILE_FIXED_MB} MB, Set, then restart Windows")
def cpu_cores():
@@ -4960,9 +5066,7 @@ def main() -> int:
(ok if ram >= need - 4 or low_ok else warn)(ram_msg) # #977: a RAM below every model's floor is not [ok]
pf = page_file_gb()
if pf is not None and pf < 4:
- warn(f"Windows' page file is {pf:.1f} GB: the graphics card's memory needs room there too (issue #60), so "
- "the model may not start or may use less VRAM. Set it to \"System managed\": System > About > "
- "Advanced system settings > Performance > Advanced > Virtual memory")
+ warn(page_file_advice(pf, page_file_setting()))
ok(f"CPU: {cpu} ({'AVX-512' if avx512 else 'AVX2' if avx2 else 'no AVX2'})")
link = None if hip else pcie_link(int(gpu.get("index", 0)))
if link is not None:
diff --git a/tools/test_setup_page_file.py b/tools/test_setup_page_file.py
new file mode 100644
index 000000000..287f51e3c
--- /dev/null
+++ b/tools/test_setup_page_file.py
@@ -0,0 +1,158 @@
+"""Step 1's page-file check: only the size the page files have for sure counts - their size now (the commit limit
+minus RAM), or a file's configured initial size when larger - never what Windows may grow them to, and the warning
+(below 4 GB, as before) advises a fixed size. When the Virtual memory setting (the registry's PagingFiles) has Windows
+grow a file on demand ("System managed", or an initial size below the maximum), the warning says why that is not
+enough (issue #60). The registry, the drives and GlobalMemoryStatusEx are mocked, so it runs on Linux too.
+
+ python -m unittest tools.test_setup_page_file
+"""
+from __future__ import annotations
+
+import contextlib
+import sys
+import types
+import unittest
+from pathlib import Path
+from unittest import mock
+
+ROOT = Path(__file__).resolve().parents[1]
+sys.path.insert(0, str(ROOT))
+sys.path.insert(0, str(ROOT / "tools"))
+import setup # noqa: E402
+from test_setup_golden import PROFILES, install # noqa: E402
+
+PAGE_FILE_GB, PAGE_FILE_SETTING = setup.page_file_gb, setup.page_file_setting # the golden harness mocks the first
+GROWS = "It is set to grow on demand"
+FIXED = f"Custom size with initial and maximum size {setup.PAGE_FILE_FIXED_MB} MB"
+
+
+def windows(paging, ram=31.9, now_mb=0, drives=None, existing=("\\??\\C:\\pagefile.sys",)):
+ """What Windows answers page_file_gb() and page_file_setting(), mocked: PagingFiles (None: it cannot be read),
+ ExistingPageFiles, each drive's (free MB, page file MB now), and GlobalMemoryStatusEx (commit limit = RAM + the
+ files' size now)."""
+ drives = {"C": (400000, now_mb)} if drives is None else drives
+ ms = types.SimpleNamespace(ullTotalPhys=int(ram * 2**30), ullTotalPageFile=int(ram * 2**30) + now_mb * 2**20)
+ return [mock.patch.object(setup, "_mm_multi_sz", lambda name: None if paging is None else
+ list(paging) if name == "PagingFiles" else list(existing)),
+ mock.patch.object(setup, "_drive_mb", lambda d: drives.get(d)),
+ mock.patch.object(setup, "_memory_status", lambda: ms)]
+
+
+def on_windows(fn):
+ def call(*a):
+ with mock.patch.object(setup, "WIN", True):
+ return fn(*a)
+ return call
+
+
+class Parse(unittest.TestCase):
+ def test_entries(self):
+ self.assertEqual(setup.parse_paging_file("c:\\pagefile.sys 64000 64000"), ("C", 64000, 64000))
+ self.assertEqual(setup.parse_paging_file("D:\\pagefile.sys 1024 32768"), ("D", 1024, 32768))
+ for managed in ("C:\\pagefile.sys 0 0", "C:\\pagefile.sys", "C:\\pagefile.sys x y"):
+ self.assertEqual(setup.parse_paging_file(managed), ("C", -1, -1), managed)
+ self.assertEqual(setup.parse_paging_file("?:\\pagefile.sys"), ("?", -1, -1)) # every drive automatic
+ for junk in ("", "x", "pagefile.sys 1 2"):
+ self.assertIsNone(setup.parse_paging_file(junk), junk)
+
+
+class Reading(unittest.TestCase):
+ def read(self, paging, **k):
+ with contextlib.ExitStack() as st:
+ for p in windows(paging, **k):
+ st.enter_context(p)
+ files = on_windows(PAGE_FILE_SETTING)()
+ return on_windows(PAGE_FILE_GB)(), files
+
+ def test_two_fixed_files(self): # this PR's author: 2 x 64000 MB on C: and D:
+ gb, files = self.read(["c:\\pagefile.sys 64000 64000", "d:\\pagefile.sys 64000 64000"], ram=127.2,
+ now_mb=128000, drives={"C": (334983, 64000), "D": (178396, 64000)})
+ self.assertEqual(gb, 125.0)
+ self.assertFalse(setup.page_file_grows(files))
+
+ def test_a_growing_file_counts_its_size_now(self):
+ for paging in (["?:\\pagefile.sys"], ["C:\\pagefile.sys 0 0"], ["C:\\pagefile.sys"]): # system-managed
+ with self.subTest(paging):
+ gb, files = self.read(paging, now_mb=4083)
+ self.assertAlmostEqual(gb, 4083 / 1024) # not 3 x RAM: it may not grow in time (#60)
+ self.assertTrue(setup.page_file_grows(files))
+ gb, files = self.read(["C:\\pagefile.sys 1024 32768"], now_mb=1024)
+ self.assertEqual(gb, 1.0) # its initial size, not its maximum
+ self.assertTrue(setup.page_file_grows(files))
+ _, files = self.read(["?:\\pagefile.sys"], now_mb=4083, existing=("\\??\\D:\\pagefile.sys",),
+ drives={"D": (100000, 4083)})
+ self.assertEqual(files, [("D", -1, -1, 4083, 100000)]) # "?:" is where Windows keeps it
+
+ def test_an_initial_size_larger_than_the_file_now_counts(self):
+ self.assertEqual(self.read(["C:\\pagefile.sys 8192 8192"], now_mb=2048, drives={"C": (400000, 2048)})[0], 8.0)
+ gb, _ = self.read(["C:\\pagefile.sys 8192 8192"], now_mb=2048, drives={"C": (1000, 2048)}) # a full drive
+ self.assertAlmostEqual(gb, 3048 / 1024)
+
+ def test_off_and_unread(self):
+ gb, files = self.read([])
+ self.assertEqual((gb, files), (0.0, []))
+ self.assertFalse(setup.page_file_grows(files))
+ gb, files = self.read(None, now_mb=4083) # the setting cannot be read: the commit limit alone
+ self.assertAlmostEqual(gb, 4083 / 1024)
+ self.assertIsNone(files)
+ self.assertFalse(setup.page_file_grows(files))
+
+ def test_not_windows(self):
+ with mock.patch.object(setup, "WIN", False):
+ self.assertIsNone(setup.page_file_gb())
+ self.assertIsNone(setup.page_file_setting())
+
+
+class Advice(unittest.TestCase):
+ def test_fixed_size_always_and_why_when_it_grows(self):
+ fixed = setup.page_file_advice(2.0, [("C", 2048, 2048, 2048, 400000)])
+ self.assertIn("Windows' page file is 2.0 GB: the graphics card's memory needs room there too", fixed)
+ self.assertIn(FIXED, fixed)
+ self.assertNotIn(GROWS, fixed)
+ self.assertNotIn("Set it to \"System managed\"", fixed)
+ for files in ([("C", -1, -1, 4083, 400000)], [("C", 1024, 32768, 1024, 400000)],
+ [("C", 2048, 2048, 2048, 400000), ("D", -1, -1, 1024, 400000)]):
+ with self.subTest(files):
+ text = setup.page_file_advice(3.99, files)
+ self.assertIn(GROWS, text)
+ self.assertIn("a fixed 64 GB worked", text)
+ self.assertIn(FIXED, text)
+ self.assertNotIn(GROWS, setup.page_file_advice(0.0, []))
+ self.assertNotIn(GROWS, setup.page_file_advice(1.0, None)) # the setting unread
+
+
+class StepOne(unittest.TestCase):
+ """setup --check on the harness's 32 GB PC with the page-file reading of a Windows PC: warned below 4 GB."""
+ WARN = "Windows' page file is"
+
+ def check(self, paging, now_mb, ram=None):
+ ram0, found = PROFILES["32GB-2x24GB"]
+ ram = ram or ram0
+ extra = [mock.patch.object(setup, "page_file_gb", on_windows(PAGE_FILE_GB)),
+ mock.patch.object(setup, "page_file_setting", on_windows(PAGE_FILE_SETTING)),
+ *windows(paging, ram=ram, now_mb=now_mb)]
+ code, out, _, _ = install(ram, found, ["--check"], extra=extra)
+ self.assertEqual(code, 0, out[-3000:])
+ return next((x for x in out.splitlines() if self.WARN in x), None)
+
+ def test_a_system_managed_file_is_warned_with_the_reason(self):
+ line = self.check(["?:\\pagefile.sys"], 4083)
+ self.assertIn("Windows' page file is 4.0 GB", line)
+ self.assertIn(GROWS, line)
+ self.assertIn(FIXED, line)
+
+ def test_a_small_fixed_file_and_none(self):
+ for paging, now in ((["C:\\pagefile.sys 2048 2048"], 2048), ([], 0)):
+ with self.subTest(paging):
+ line = self.check(paging, now)
+ self.assertIn(f"Windows' page file is {now / 1024:.1f} GB", line)
+ self.assertIn(FIXED, line)
+ self.assertNotIn(GROWS, line)
+
+ def test_the_threshold_is_unchanged(self):
+ self.assertIsNone(self.check(["?:\\pagefile.sys"], 8192)) # 8 GB now: not warned, as before
+ self.assertIsNone(self.check(["C:\\pagefile.sys 64000 64000"], 64000))
+
+
+if __name__ == "__main__":
+ unittest.main()