diff --git a/src/components/StatusBar.tsx b/src/components/StatusBar.tsx index cc7d996..cdb19ba 100644 --- a/src/components/StatusBar.tsx +++ b/src/components/StatusBar.tsx @@ -103,7 +103,7 @@ export const StatusBar = ({ => { if (gpuMemoryInfo) { const lowVramGpus = gpuMemoryInfo.filter( (gpu) => - typeof gpu.totalMemoryMB === 'number' && gpu.totalMemoryMB < 8192 + typeof gpu.totalMemoryGB === 'number' && gpu.totalMemoryGB < 8 ); if (lowVramGpus.length > 0) { @@ -127,7 +127,7 @@ const checkVramWarnings = async (backend: string): Promise => { message: `Low VRAM detected (${lowVramGpus .map( (gpu) => - `${gpu.deviceName}: ${(gpu.totalMemoryMB! / 1024).toFixed(1)}GB` + `${gpu.deviceName}: ${gpu.totalMemoryGB!.toFixed(1)}GB` ) .join( ', ' diff --git a/src/main/modules/hardware.ts b/src/main/modules/hardware.ts index 8d3dcec..7bf493a 100644 --- a/src/main/modules/hardware.ts +++ b/src/main/modules/hardware.ts @@ -444,7 +444,7 @@ export async function detectGPUMemory() { memoryInfo.push({ deviceName: formatDeviceName(gpu.deviceName), - totalMemoryMB: vram, + totalMemoryGB: vram, }); } } diff --git a/src/main/modules/monitoring.ts b/src/main/modules/monitoring.ts index 9007147..a11421c 100644 --- a/src/main/modules/monitoring.ts +++ b/src/main/modules/monitoring.ts @@ -106,10 +106,12 @@ async function collectAndSendCpuMetrics() { async function collectAndSendMemoryMetrics() { try { const memData = await si.mem(); + const usedBytes = memData.active || memData.used; + const totalBytes = memData.total; const metrics: MemoryMetrics = { - used: memData.active || memData.used, - total: memData.total, - usage: ((memData.active || memData.used) / memData.total) * 100, + used: Math.round(usedBytes / (1024 * 1024 * 1024) * 10) / 10, + total: Math.round(totalBytes / (1024 * 1024 * 1024) * 10) / 10, + usage: (usedBytes / totalBytes) * 100, }; if (mainWindow && !mainWindow.isDestroyed()) { diff --git a/src/types/hardware.d.ts b/src/types/hardware.d.ts index 65e89ad..5471bc9 100644 --- a/src/types/hardware.d.ts +++ b/src/types/hardware.d.ts @@ -6,7 +6,7 @@ export interface CPUCapabilities { export interface GPUMemoryInfo { deviceName: string; - totalMemoryMB: number | null; + totalMemoryGB: number | null; } export interface GPUCapabilities { diff --git a/src/utils/gpu.ts b/src/utils/gpu.ts index e85691e..16009ea 100644 --- a/src/utils/gpu.ts +++ b/src/utils/gpu.ts @@ -167,9 +167,9 @@ foreach ($gpu in $gpus) { gpus.push({ deviceName: name, usage: Math.round(utilization * 100) / 100, - memoryUsed: usedRAM > 0 ? Math.round(usedRAM / (1024 * 1024)) : 0, + memoryUsed: usedRAM > 0 ? Math.round(usedRAM / (1024 * 1024 * 1024)) : 0, memoryTotal: - totalRAM > 0 ? Math.round(totalRAM / (1024 * 1024)) : 0, + totalRAM > 0 ? Math.round(totalRAM / (1024 * 1024 * 1024)) : 0, }); } } @@ -214,8 +214,12 @@ async function getLinuxGPUData() { ); const usage = parseInt(usageData.trim(), 10) || 0; - const memoryUsed = parseInt(memUsedData.trim(), 10) || 0; - const memoryTotal = parseInt(memTotalData.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) + ); gpus.push({ deviceName: 'GPU',