CodeBench: tyhjennä GPU-muisti jokaisen kierroksen alussa
clearVram()-funktio vapauttaa kaikki Ollama-mallit VRAM:sta ennen testiä.
This commit is contained in:
@@ -522,6 +522,22 @@ async function runPipeline(model, scenario) {
|
|||||||
return result;
|
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 ===
|
// === Main ===
|
||||||
async function main() {
|
async function main() {
|
||||||
console.log('╔══════════════════════════════════════════════╗');
|
console.log('╔══════════════════════════════════════════════╗');
|
||||||
@@ -538,20 +554,6 @@ async function main() {
|
|||||||
process.exit(1);
|
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) {
|
if (FILTER_MODELS) {
|
||||||
const filter = FILTER_MODELS.split(',').map(s => s.trim());
|
const filter = FILTER_MODELS.split(',').map(s => s.trim());
|
||||||
models = models.filter(m => filter.some(f => m.includes(f)));
|
models = models.filter(m => filter.some(f => m.includes(f)));
|
||||||
@@ -574,6 +576,7 @@ async function main() {
|
|||||||
const results = [];
|
const results = [];
|
||||||
|
|
||||||
for (let round = 1; round <= ROUNDS; round++) {
|
for (let round = 1; round <= ROUNDS; round++) {
|
||||||
|
await clearVram();
|
||||||
if (ROUNDS > 1) console.log(`\n╔═══ Kierros ${round}/${ROUNDS} ═══╗`);
|
if (ROUNDS > 1) console.log(`\n╔═══ Kierros ${round}/${ROUNDS} ═══╗`);
|
||||||
for (const model of models) {
|
for (const model of models) {
|
||||||
for (const scenario of scenarios) {
|
for (const scenario of scenarios) {
|
||||||
|
|||||||
Reference in New Issue
Block a user