Files
gnome-jarvis/daemon/gpu-doctor.js
T
snxraven fee584673d
Rolling release / release (push) Failing after 21m6s
Close QVAC after GPU preflight
2026-09-11 16:24:35 -04:00

41 lines
1.4 KiB
JavaScript

import { Agent, assertSdkVersion } from './qvac-master.js';
import { MODEL_PROFILES } from './model-profiles.js';
try {
const sdkVersion = assertSdkVersion();
const resources = await Agent.engine.resources();
const hasGpu = Array.isArray(resources.gpus) && resources.gpus.length > 0;
console.log(JSON.stringify({
policy: 'gpu-required',
hasGpu,
backendHints: resources.drivers || {},
gpus: resources.gpus || [],
vramBytes: resources.vramBytes || 0,
sdkVersion,
profiles: MODEL_PROFILES,
}, null, 2));
if (!hasGpu) {
console.error('gpu-doctor: QVAC did not observe a usable GPU; Jarvis will refuse CPU inference');
process.exitCode = 1;
}
} catch (error) {
console.error(`gpu-doctor: ${error.message}`);
process.exitCode = 1;
} finally {
// Resource discovery initializes QVAC handles even without loading a model.
// This one-shot command owns them and must close them before returning to
// first-run. Bound cleanup in case a native handle never settles.
const watchdog = setTimeout(() => {
console.error('gpu-doctor: QVAC cleanup timed out');
process.exit(1);
}, 5000);
try {
await Agent.engine.close();
} finally {
clearTimeout(watchdog);
}
// Bare addons may retain handles after close; this diagnostic has no more
// work to do. Never put this exit in the shared daemon/runtime lifecycle.
if (globalThis.Bare) Bare.exit(process.exitCode || 0);
}