mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 04:38:33 +00:00
fix(engine): use static import for execSync, unify VRAM cap at 16GB
- Replace require("child_process") with static import (same ESM fix
as config.ts — require is undefined in native ESM)
- Unify cap: both VRAM probe and heuristic paths now cap at 16GB
- Add comment noting the one-time blocking execSync is cached
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
import type { Browser, PuppeteerNode } from "puppeteer-core";
|
||||
import { execSync } from "child_process";
|
||||
import { existsSync, readdirSync } from "fs";
|
||||
import { join } from "path";
|
||||
import { homedir, totalmem } from "os";
|
||||
@@ -485,7 +486,7 @@ let _cachedVramMb: number | null = null;
|
||||
function probeNvidiaVramMb(): number | null {
|
||||
if (_cachedVramMb !== null) return _cachedVramMb;
|
||||
try {
|
||||
const { execSync } = require("child_process") as typeof import("child_process");
|
||||
// Synchronous, runs once per process (cached). ~50ms on typical systems.
|
||||
const out = execSync("nvidia-smi --query-gpu=memory.total --format=csv,noheader,nounits", {
|
||||
timeout: 3000,
|
||||
encoding: "utf-8",
|
||||
@@ -504,7 +505,7 @@ function probeNvidiaVramMb(): number | null {
|
||||
|
||||
function getGpuMemBudgetMb(): number {
|
||||
const vram = probeNvidiaVramMb();
|
||||
if (vram) return Math.min(vram, 65536);
|
||||
if (vram) return Math.min(vram, 16384);
|
||||
|
||||
const total = getTotalMemMb();
|
||||
if (total < 4096) return 512;
|
||||
|
||||
Reference in New Issue
Block a user