re-fix for linux

This commit is contained in:
lone-cloud 2025-09-10 17:24:44 -07:00
parent 280ae26d77
commit f1739d810f
6 changed files with 19 additions and 13 deletions

View file

@ -103,7 +103,7 @@ export const StatusBar = ({
</Tooltip>
<Tooltip
label={`${(memoryMetrics.used / 1024 ** 3).toFixed(1)} GB / ${(memoryMetrics.total / 1024 ** 3).toFixed(1)} GB (${memoryMetrics.usage.toFixed(1)}%)`}
label={`${memoryMetrics.used.toFixed(1)} GB / ${memoryMetrics.total.toFixed(1)} GB (${memoryMetrics.usage.toFixed(1)}%)`}
position="top"
>
<Badge
@ -128,7 +128,7 @@ export const StatusBar = ({
</Tooltip>
<Tooltip
label={`${(gpu.memoryUsed / 1024).toFixed(1)} GB / ${(gpu.memoryTotal / 1024).toFixed(1)} GB (${gpu.memoryUsage.toFixed(1)}%)`}
label={`${gpu.memoryUsed.toFixed(1)} GB / ${gpu.memoryTotal.toFixed(1)} GB (${gpu.memoryUsage.toFixed(1)}%)`}
position="top"
>
<Badge

View file

@ -118,7 +118,7 @@ const checkVramWarnings = async (backend: string): Promise<Warning[]> => {
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<Warning[]> => {
message: `Low VRAM detected (${lowVramGpus
.map(
(gpu) =>
`${gpu.deviceName}: ${(gpu.totalMemoryMB! / 1024).toFixed(1)}GB`
`${gpu.deviceName}: ${gpu.totalMemoryGB!.toFixed(1)}GB`
)
.join(
', '

View file

@ -444,7 +444,7 @@ export async function detectGPUMemory() {
memoryInfo.push({
deviceName: formatDeviceName(gpu.deviceName),
totalMemoryMB: vram,
totalMemoryGB: vram,
});
}
}

View file

@ -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()) {

View file

@ -6,7 +6,7 @@ export interface CPUCapabilities {
export interface GPUMemoryInfo {
deviceName: string;
totalMemoryMB: number | null;
totalMemoryGB: number | null;
}
export interface GPUCapabilities {

View file

@ -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',