From d003f73217a68dbc5b443ceff26c8b65a920d7cf Mon Sep 17 00:00:00 2001 From: jaakko Date: Tue, 14 Apr 2026 17:47:55 +0300 Subject: [PATCH] =?UTF-8?q?CodeBench:=20tyhjenn=C3=A4=20GPU-muisti=20jokai?= =?UTF-8?q?sen=20kierroksen=20alussa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit clearVram()-funktio vapauttaa kaikki Ollama-mallit VRAM:sta ennen testiä. --- kipina-codebench/benchmark.mjs | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) 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) {