diff --git a/kipina-codebench/benchmark.mjs b/kipina-codebench/benchmark.mjs index 4239438..7756196 100644 --- a/kipina-codebench/benchmark.mjs +++ b/kipina-codebench/benchmark.mjs @@ -522,6 +522,22 @@ async function runPipeline(model, scenario) { return result; } +// === GPU-muistin tyhjennys === +async function clearVram() { + try { + const psResp = await fetch(`${OLLAMA_URL}/api/ps`); + const psData = await psResp.json(); + for (const m of (psData.models || [])) { + await fetch(`${OLLAMA_URL}/api/generate`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ model: m.name, keep_alive: 0 }), + }); + console.log(` ♻ Vapautettu: ${m.name}`); + } + } catch (e) { /* ei kriittinen */ } +} + // === Main === async function main() { console.log('╔══════════════════════════════════════════════╗'); @@ -538,20 +554,6 @@ async function main() { process.exit(1); } - // Tyhjennä VRAM — vapauta kaikki ladatut mallit - try { - const psResp = await fetch(`${OLLAMA_URL}/api/ps`); - const psData = await psResp.json(); - for (const m of (psData.models || [])) { - await fetch(`${OLLAMA_URL}/api/generate`, { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ model: m.name, keep_alive: 0 }), - }); - console.log(` ♻ Vapautettu: ${m.name}`); - } - } catch (e) { /* ei kriittinen */ } - if (FILTER_MODELS) { const filter = FILTER_MODELS.split(',').map(s => s.trim()); models = models.filter(m => filter.some(f => m.includes(f))); @@ -574,6 +576,7 @@ async function main() { const results = []; for (let round = 1; round <= ROUNDS; round++) { + await clearVram(); if (ROUNDS > 1) console.log(`\n╔═══ Kierros ${round}/${ROUNDS} ═══╗`); for (const model of models) { for (const scenario of scenarios) {