// deno-lint-ignore-file no-unversioned-import no-import-prefix
import si from "npm:systeminformation";
let VRAM: number | undefined = undefined;
export const get_vram_auto = async () => {
try {
const graphics = await si.graphics();
graphics.controllers.forEach(gpu => {
const vram = gpu.vram ? gpu.vram / 1024 : null;
if(vram && (typeof VRAM == 'undefined' || vram > VRAM)) VRAM = vram;
});
} catch (error) {
console.error("Failed to fetch GPU info:", error);
}
return VRAM;
}
export const get_vram = () => {
const num = prompt('How much VRAM does the current GPU have, in GB?');
if(num === null) Deno.exit(0);
const parsed = parseInt(num);
if(isNaN(parsed) || parsed < 2 || parsed > 100) return undefined;
return parsed;
}