From f935401dff56c9944815211c96f2c2af4e81e104 Mon Sep 17 00:00:00 2001 From: lone-cloud Date: Wed, 10 Sep 2025 18:49:49 -0700 Subject: [PATCH] better monitor: fix excessive VRAM rounding --- package.json | 2 +- src/hooks/useWarnings.ts | 6 ++---- src/main/modules/monitoring.ts | 3 ++- src/utils/gpu.ts | 15 ++++++--------- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index b6627d2..3be27a7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "gerbil", "productName": "Gerbil", - "version": "1.1.1", + "version": "1.1.2", "description": "Run Large Language Models locally", "main": "out/main/index.js", "homepage": "./", diff --git a/src/hooks/useWarnings.ts b/src/hooks/useWarnings.ts index 7f21f3f..712fb10 100644 --- a/src/hooks/useWarnings.ts +++ b/src/hooks/useWarnings.ts @@ -117,8 +117,7 @@ const checkVramWarnings = async (backend: string): Promise => { if (gpuMemoryInfo) { const lowVramGpus = gpuMemoryInfo.filter( - (gpu) => - typeof gpu.totalMemoryGB === 'number' && gpu.totalMemoryGB < 8 + (gpu) => typeof gpu.totalMemoryGB === 'number' && gpu.totalMemoryGB < 8 ); if (lowVramGpus.length > 0) { @@ -126,8 +125,7 @@ const checkVramWarnings = async (backend: string): Promise => { type: 'warning', message: `Low VRAM detected (${lowVramGpus .map( - (gpu) => - `${gpu.deviceName}: ${gpu.totalMemoryGB!.toFixed(1)}GB` + (gpu) => `${gpu.deviceName}: ${gpu.totalMemoryGB!.toFixed(1)}GB` ) .join( ', ' diff --git a/src/main/modules/monitoring.ts b/src/main/modules/monitoring.ts index c606d53..c58c713 100644 --- a/src/main/modules/monitoring.ts +++ b/src/main/modules/monitoring.ts @@ -1,3 +1,4 @@ +import { platform } from 'process'; import si from 'systeminformation'; import { BrowserWindow } from 'electron'; import { logError } from '@/main/modules/logging'; @@ -45,7 +46,7 @@ let cpuInterval: ReturnType | null = null; let memoryInterval: ReturnType | null = null; let gpuInterval: ReturnType | null = null; let isRunning = false; -const updateFrequency = 2000; +const updateFrequency = platform === 'win32' ? 2000 : 1000; let mainWindow: BrowserWindow | null = null; export function startMonitoring(window: BrowserWindow) { diff --git a/src/utils/gpu.ts b/src/utils/gpu.ts index 16009ea..6360d1d 100644 --- a/src/utils/gpu.ts +++ b/src/utils/gpu.ts @@ -167,9 +167,8 @@ foreach ($gpu in $gpus) { gpus.push({ deviceName: name, usage: Math.round(utilization * 100) / 100, - memoryUsed: usedRAM > 0 ? Math.round(usedRAM / (1024 * 1024 * 1024)) : 0, - memoryTotal: - totalRAM > 0 ? Math.round(totalRAM / (1024 * 1024 * 1024)) : 0, + memoryUsed: usedRAM > 0 ? usedRAM / (1024 * 1024 * 1024) : 0, + memoryTotal: totalRAM > 0 ? totalRAM / (1024 * 1024 * 1024) : 0, }); } } @@ -214,12 +213,10 @@ async function getLinuxGPUData() { ); const usage = parseInt(usageData.trim(), 10) || 0; - const memoryUsed = Math.round( - (parseInt(memUsedData.trim(), 10) || 0) / (1024 * 1024 * 1024) - ); - const memoryTotal = Math.round( - (parseInt(memTotalData.trim(), 10) || 0) / (1024 * 1024 * 1024) - ); + const memoryUsed = + (parseInt(memUsedData.trim(), 10) || 0) / (1024 * 1024 * 1024); + const memoryTotal = + (parseInt(memTotalData.trim(), 10) || 0) / (1024 * 1024 * 1024); gpus.push({ deviceName: 'GPU',