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++

A build for another make of graphics card says so in plain words with the right download and is not unpacked (I)

Niko12215c9884cdee68
diff --git a/apps/host/server/bundled-engine.mjs b/apps/host/server/bundled-engine.mjs
index 12cea7ac6..43aab1daf 100644
--- a/apps/host/server/bundled-engine.mjs
+++ b/apps/host/server/bundled-engine.mjs
@@ -9,7 +9,7 @@
* The copy is made under a hidden temporary name and renamed into place, so an interrupted run leaves nothing half-installed
* (the next start removes the leftover and tries again).
*/
-import { createReadStream, existsSync, readFileSync } from 'node:fs';
+import { createReadStream, existsSync, readFileSync, readdirSync } from 'node:fs';
import { execFileSync } from 'node:child_process';
import { copyFile, mkdir, readdir, readFile, rename, rm, stat } from 'node:fs/promises';
import { createHash } from 'node:crypto';
@@ -64,6 +64,40 @@ export function nvidiaDriverVersion() {
return null;
}
+/** Where the builds are published; the wrong-make sentence points here. */
+export const RELEASES_URL = 'https://github.com/Niko1221/Strata/releases';
+
+/**
+ * The engine family this PC's graphics card needs ('cuda', 'hip', 'sycl'), or null when it cannot be told. The same order as Control
+ * (NVIDIA first, then AMD, then Intel); STRATA_ENGINE_BACKEND wins. Reads only the driver and (Linux) the PCI vendor of the display adapters.
+ */
+export function gpuBackendHere(env = process.env) {
+ const forced = String(env.STRATA_ENGINE_BACKEND ?? '').trim().toLowerCase();
+ if (forced) return ['cuda', 'hip', 'sycl'].includes(forced) ? forced : null;
+ if (nvidiaDriverVersion()) return 'cuda';
+ try {
+ const base = '/sys/class/drm';
+ const vendors = new Set();
+ for (const card of readdirSync(base)) {
+ if (!/^card\d+$/.test(card)) continue;
+ try { vendors.add(readFileSync(`${base}/${card}/device/vendor`, 'utf8').trim().toLowerCase()); } catch { /* no vendor file */ }
+ }
+ for (const [vendor, backend] of [['0x10de', 'cuda'], ['0x1002', 'hip'], ['0x8086', 'sycl']]) if (vendors.has(vendor)) return backend;
+ } catch { /* not Linux */ }
+ return null;
+}
+
+const HIP_FAMILIES = [['RX 9000', ['gfx1200', 'gfx1201']], ['RX 7000', ['gfx1100', 'gfx1101', 'gfx1102']], ['RX 6000', ['gfx1030', 'gfx1031']], ['Ryzen AI Max', ['gfx1151']]];
+const MAKE_NAME = { cuda: 'NVIDIA', hip: 'AMD', sycl: 'Intel' };
+
+/** The plain sentence for a build made for another make of graphics card than this PC has. */
+export function wrongMakeNotice(manifest, here) {
+ const built = manifest.backend;
+ const families = [...new Set((manifest.archs ?? []).map(a => HIP_FAMILIES.find(([, list]) => list.includes(a))?.[0]).filter(Boolean))];
+ const builtFor = built === 'hip' && families.length ? `AMD ${families.join(' and ')}` : MAKE_NAME[built] ?? built;
+ return `This Strata is for ${builtFor} cards. Your PC has an ${MAKE_NAME[here] ?? here} card: download the ${MAKE_NAME[here] ?? here} version from ${RELEASES_URL}`;
+}
+
/** One engine can ship as several builds of the same backend (CUDA 13 and CUDA 12 differ in the oldest driver they run on). */
const variantOf = manifest => `${manifest.platform}/${manifest.backend}/${manifest.min_driver?.nvidia ?? ''}`;
@@ -85,7 +119,7 @@ export async function packageIsWhole(folder, manifest, { deep = false } = {}) {
* Install the bundled engine when it is needed.
* Returns { action: 'installed' | 'repaired' | 'kept' | 'none' | 'refused', folder?, version?, reason? }; never throws.
*/
-export async function installBundledEngine({ bundleDir, components, platform = null, log = () => {}, driver = undefined } = {}) {
+export async function installBundledEngine({ bundleDir, components, platform = null, log = () => {}, driver = undefined, backend = undefined } = {}) {
try {
if (!bundleDir || !components || !existsSync(bundleDir)) return { action: 'none' };
let packages = [];
@@ -96,6 +130,17 @@ export async function installBundledEngine({ bundleDir, components, platform = n
}
if (platform) packages = packages.filter(p => p.manifest.platform === platform);
if (!packages.length) return { action: 'none' };
+ // A build for another make of graphics card than this PC has can never run here: it is not unpacked, and the caller says so in plain words.
+ const wanted = backend === undefined ? gpuBackendHere() : backend;
+ if (wanted && ['cuda', 'hip', 'sycl'].includes(wanted)) {
+ const gpu = packages.filter(p => ['cuda', 'hip', 'sycl'].includes(p.manifest.backend));
+ const fits = packages.filter(p => !gpu.includes(p) || p.manifest.backend === wanted);
+ if (gpu.length && !fits.length) {
+ const first = gpu.sort((a, b) => compareVersions(b.manifest.version, a.manifest.version))[0].manifest;
+ return { action: 'wrong-make', built: first.backend, here: wanted, notice: wrongMakeNotice(first, wanted) };
+ }
+ packages = fits;
+ }
// The CUDA builds the NVIDIA driver here can run: all of them when the driver is unknown or fits several; when none fits, the one with the lowest
// requirement, so that Control can name the driver to install (copying the others would only waste disk).
const driverHere = driver === undefined ? nvidiaDriverVersion() : driver;
diff --git a/apps/host/server/native-control.mjs b/apps/host/server/native-control.mjs
index 94bf6c571..ae4ec6485 100644
--- a/apps/host/server/native-control.mjs
+++ b/apps/host/server/native-control.mjs
@@ -102,7 +102,7 @@ export function createNativeControl({directory,requests=()=>[],changed=()=>{},sp
const models=(list.models??[]).filter(m=>m.component_status!=='invalid'&&m.source_config).map(m=>({...(disk[m.id]??{}),model:m.id,config:basename(m.source_config),configPath:m.source_config,model_name:m.name,context:m.context_tokens??0,backend:m.backend,ready:m.component_status==='present'&&!(disk[m.id]?.partsMissing),images:'off',port:undefined,last_used:null}));
const cores=os.cpus().length;
return {summary:engine.usable?`Strata Control is ready; engine ${engine.engine.version} (${engine.engine.platform}-${engine.engine.backend}).`:(engine.notice??'No engine for this PC was found.'),
- installDir:list.install_dir,engine:{usable:engine.usable,notice:engine.notice,version:engine.engine?.version??null,backend:engine.backend,componentsDir:engine.components_dir,previous:engine.previous??null,pinned:engine.pinned??null,updateNotice:engine.update_notice??null},
+ installDir:list.install_dir,engine:{usable:engine.usable,notice:engine.notice,wrongMake:engine.wrongMake===true,version:engine.engine?.version??null,backend:engine.backend,componentsDir:engine.components_dir,previous:engine.previous??null,pinned:engine.pinned??null,updateNotice:engine.update_notice??null},
installed:{strata_folder:list.install_dir,data_folder:null,engine:engine.engine?{version:engine.engine.version,backend:engine.engine.backend,folder:engine.engine.root}:{folder:null,version:null},models,usage:installer.installed?.usage??null},
hardware:installer.hardware?{...installer.hardware,cpu:{...(installer.hardware.cpu??{}),cores:installer.hardware.cpu?.cores??cores},gpus:installer.hardware.gpus??[]}:{cpu:{cores},ram_gb:Math.round(os.totalmem()/1024**3),gpus:[]},
recommendation:installer.recommendation??null,installerError:installer.error??null,install:installer.install??null,running:null};
diff --git a/apps/host/src/components/EngineWarning.tsx b/apps/host/src/components/EngineWarning.tsx
index cbaa13c9e..277e8892c 100644
--- a/apps/host/src/components/EngineWarning.tsx
+++ b/apps/host/src/components/EngineWarning.tsx
@@ -8,5 +8,6 @@ export const engineMissing = (native: NativeState | null | undefined) => !!nativ
export function EngineWarning({ native }: { native: NativeState | null | undefined }) {
if (!engineMissing(native)) return null;
+ if (native?.engine?.wrongMake && native.engine.notice) return <div className="engine-warning" role="status"><Icon name="info" size={18}/><div><p>{native.engine.notice}</p></div></div>;
return <div className="engine-warning" role="status"><Icon name="info" size={18}/><div><p>{tr("Strata didn’t recognise an engine for this computer. The model will download, but it may not run until the right engine is installed (Settings → Engine).")}</p>{native?.engine?.notice ? <small className="muted">{native.engine.notice}</small> : null}</div></div>;
}
diff --git a/apps/host/src/lib/native.ts b/apps/host/src/lib/native.ts
index 2d0f5c2de..1202a868b 100644
--- a/apps/host/src/lib/native.ts
+++ b/apps/host/src/lib/native.ts
@@ -11,7 +11,7 @@ export interface NativeInstance {id:string;apiModelId:string;model:string;label:
export interface NativeState {
/** The picture reader (strata-vision) is installed with the engine, so models marked for pictures can read them here. */
/** Strata Control's view of the engine for this computer (the app): usable false = none found or recognised; `notice` says why in plain words. */
- engine?:{usable:boolean;notice?:string|null;version?:string|null};
+ engine?:{usable:boolean;notice?:string|null;wrongMake?:boolean;version?:string|null};
visionReader?: boolean;available:boolean;repo:string;downloadDirectory?:string;version?:string|null;summary:string;error:string|null;catalog:{families:NativeFamily[];contexts:number[];recommendation:{family:string|null;model:string|null;context?:number;why?:string};context_note:string}|null;installed:{models:{model:string;config:string;model_name:string;ready:boolean;/** The picture-reading files are on this computer (notes-split-agent8.md, item 8). */visionPrepared?:boolean;context?:number;kv?:string;images?:string;visionEnabled?:boolean;visionDevice?:string;lowRamMode?:string;resourceProfile?:'work'|'performance';dataFolder?:string;diskGb?:number;diskBytes?:number;/** Files this model shares with another (the picture reader, the draft layer): counted once, in `usage`. */sharedBytes?:number;/** What Delete frees: files in Strata's own folders that no other model uses. */removableGb?:number;missing_files?:string[]}[];/** What all models take on disk, from their real files, shared files counted once. */usage?:{total_bytes:number;total_gb:number;shared_bytes:number;shared_gb:number;models:Record<string,{bytes:number;gb:number}>}|null;data_folder:string;engine:{version:string|null}}|null;hardware:{ram_gb:number;gpus:{index:number;name:string;vram_gb:number;usable:boolean}[]}|null;fields:NativeField[];instances:NativeInstance[];defaultId:string|null;jobs:NativeJob[];capabilities:{responses?:boolean;updates:boolean;rollback:boolean;calibration:boolean;componentUpdates?:boolean}}
let state:NativeState|null=null;
const listeners=new Set<()=>void>();
diff --git a/apps/host/tests/bundled-engine.test.mjs b/apps/host/tests/bundled-engine.test.mjs
index 29a369ee0..726556267 100644
--- a/apps/host/tests/bundled-engine.test.mjs
+++ b/apps/host/tests/bundled-engine.test.mjs
@@ -5,8 +5,10 @@ import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, existsSync, readdi
import { createHash } from 'node:crypto';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
-import { installBundledEngine, compareVersions } from '../server/bundled-engine.mjs';
+import { installBundledEngine, compareVersions, wrongMakeNotice } from '../server/bundled-engine.mjs';
+// the make of card is read from this computer unless a test names it; the existing tests are written for an NVIDIA PC
+process.env.STRATA_ENGINE_BACKEND = 'cuda';
const sha = buffer => createHash('sha256').update(buffer).digest('hex');
function makePackage(root, version, { body = 'engine-' + version, backend = 'cuda', platform = 'windows-x86_64', variant = 'cuda13', minDriver = null } = {}) {
const name = `${version}-${platform}-${backend}-${variant}`;
@@ -150,3 +152,24 @@ test('why the update carries no engine: a CUDA installer on an AMD PC would copy
assert.deepEqual(readdirSync(t.engine).sort(), [amd, cuda].sort(), 'the AMD engine stays; a useless CUDA engine is added');
} finally { t.cleanup(); }
});
+
+test('an AMD build on an NVIDIA PC is not unpacked and the sentence names the right download', async () => {
+ const t = setup();
+ try {
+ const name = makePackage(t.bundle, '0.2.0', { platform: 'linux-x86_64', backend: 'hip', variant: 'rx9070' });
+ const manifest = JSON.parse(readFileSync(join(t.bundle, name, 'engine-component.json'), 'utf8'));
+ manifest.archs = ['gfx1201'];
+ writeFileSync(join(t.bundle, name, 'engine-component.json'), JSON.stringify(manifest));
+ const result = await installBundledEngine({ bundleDir: t.bundle, components: t.components, backend: 'cuda' });
+ assert.equal(result.action, 'wrong-make');
+ assert.equal(result.notice, 'This Strata is for AMD RX 9000 cards. Your PC has an NVIDIA card: download the NVIDIA version from https://github.com/Niko1221/Strata/releases');
+ assert.equal(existsSync(t.engine), false, 'nothing was copied');
+ // the same build on an AMD PC is unpacked; an unknown card is not a reason to refuse
+ assert.equal((await installBundledEngine({ bundleDir: t.bundle, components: t.components, backend: 'hip' })).action, 'installed');
+ assert.equal((await installBundledEngine({ bundleDir: t.bundle, components: t.components, backend: null })).action, 'kept');
+ } finally { t.cleanup(); }
+});
+
+test('wrongMakeNotice names the make, not a list of reasons', () => {
+ assert.equal(wrongMakeNotice({ backend: 'cuda', archs: ['sm_86'] }, 'hip'), 'This Strata is for NVIDIA cards. Your PC has an AMD card: download the AMD version from https://github.com/Niko1221/Strata/releases');
+});
diff --git a/strata_control/engine_component.py b/strata_control/engine_component.py
index b8c554423..b23c52d1c 100644
--- a/strata_control/engine_component.py
+++ b/strata_control/engine_component.py
@@ -647,6 +647,18 @@ def arch_notice(built: tuple[str, ...], here: list[str]) -> str:
f"Ask for the {make(have)} build.")
+RELEASES_URL = "https://github.com/Niko1221/Strata/releases"
+MAKE_NAMES = {"cuda": "NVIDIA", "hip": "AMD", "sycl": "Intel"}
+
+
+def wrong_make_notice(built: str, archs: tuple[str, ...], here: str) -> str:
+ """The plain sentence for a build made for another make of graphics card than this computer has (an AMD build on an NVIDIA PC)."""
+ families = sorted({hip_family(a) for a in archs if any(a in group for _, group in HIP_FAMILIES)})
+ built_for = f"AMD {' and '.join(families)}" if built == "hip" and families else MAKE_NAMES.get(built, built)
+ make = MAKE_NAMES.get(here, here)
+ return f"This Strata is for {built_for} cards. Your PC has an {make} card: download the {make} version from {RELEASES_URL}"
+
+
def resolve(root: Path | None = None, *, backend: str | None = None, target: str | None = None,
full: bool = False, runtime: str | None = None) -> EngineComponent:
"""The engine to start on this machine, or `EngineMissing` / `EngineIntegrityError`. Never downloads, never creates
@@ -714,6 +726,12 @@ def resolve(root: Path | None = None, *, backend: str | None = None, target: str
plain = None
if arch_blocked and len(arch_blocked) == compatible and not broken: # every engine that fits this PC is built for other cards
plain = arch_notice(tuple(sorted({a for item in arch_blocked for a in item.hip_archs})), hip_here)
+ if plain is None and not compatible and not broken and wanted in MAKE_NAMES: # every engine here is for another make of card
+ here_target = [item for item in found if item.platform == target]
+ other = [item for item in here_target if item.backend in MAKE_NAMES and item.backend != wanted]
+ if other and len(other) == len(here_target):
+ top = max(other, key=lambda item: _version_key(item.version))
+ plain = wrong_make_notice(top.backend, top.archs, wanted)
missing = EngineMissing("; ".join(everything) or "nothing matched", base, problems=problems, notice=plain)
if driver_blocked and len(driver_blocked) == compatible and not broken:
# the only thing in the way is the NVIDIA driver: one plain line that names the version to install
diff --git a/tests/terminal/test_engine_component.py b/tests/terminal/test_engine_component.py
index 7b801aabf..24caae89a 100644
--- a/tests/terminal/test_engine_component.py
+++ b/tests/terminal/test_engine_component.py
@@ -312,6 +312,12 @@ class WrongCardFamily(unittest.TestCase):
self.assertIn("(gfx1100)", note)
self.assertNotIn("component", note)
+ def test_an_amd_build_on_an_nvidia_pc_names_the_nvidia_download(self):
+ with mock.patch.object(ec, "hip_archs_present", return_value=[]):
+ note = ec.status(self.root, backend="cuda")["notice"]
+ self.assertTrue(note.startswith("This Strata is for AMD RX 9000 cards. Your PC has an NVIDIA card: download the NVIDIA version from "), note)
+ self.assertIn("https://github.com/Niko1221/Strata/releases", note)
+
def test_the_matching_family_is_not_blocked(self):
with mock.patch.object(ec, "hip_archs_present", return_value=["gfx1201"]):
self.assertEqual(ec.resolve(self.root, backend="hip", runtime="1").backend, "hip")