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>
<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" position="top"
> >
<Badge <Badge
@ -128,7 +128,7 @@ export const StatusBar = ({
</Tooltip> </Tooltip>
<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" position="top"
> >
<Badge <Badge

View file

@ -118,7 +118,7 @@ const checkVramWarnings = async (backend: string): Promise<Warning[]> => {
if (gpuMemoryInfo) { if (gpuMemoryInfo) {
const lowVramGpus = gpuMemoryInfo.filter( const lowVramGpus = gpuMemoryInfo.filter(
(gpu) => (gpu) =>
typeof gpu.totalMemoryMB === 'number' && gpu.totalMemoryMB < 8192 typeof gpu.totalMemoryGB === 'number' && gpu.totalMemoryGB < 8
); );
if (lowVramGpus.length > 0) { if (lowVramGpus.length > 0) {
@ -127,7 +127,7 @@ const checkVramWarnings = async (backend: string): Promise<Warning[]> => {
message: `Low VRAM detected (${lowVramGpus message: `Low VRAM detected (${lowVramGpus
.map( .map(
(gpu) => (gpu) =>
`${gpu.deviceName}: ${(gpu.totalMemoryMB! / 1024).toFixed(1)}GB` `${gpu.deviceName}: ${gpu.totalMemoryGB!.toFixed(1)}GB`
) )
.join( .join(
', ' ', '

View file

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

View file

@ -106,10 +106,12 @@ async function collectAndSendCpuMetrics() {
async function collectAndSendMemoryMetrics() { async function collectAndSendMemoryMetrics() {
try { try {
const memData = await si.mem(); const memData = await si.mem();
const usedBytes = memData.active || memData.used;
const totalBytes = memData.total;
const metrics: MemoryMetrics = { const metrics: MemoryMetrics = {
used: memData.active || memData.used, used: Math.round(usedBytes / (1024 * 1024 * 1024) * 10) / 10,
total: memData.total, total: Math.round(totalBytes / (1024 * 1024 * 1024) * 10) / 10,
usage: ((memData.active || memData.used) / memData.total) * 100, usage: (usedBytes / totalBytes) * 100,
}; };
if (mainWindow && !mainWindow.isDestroyed()) { if (mainWindow && !mainWindow.isDestroyed()) {

View file

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

View file

@ -167,9 +167,9 @@ foreach ($gpu in $gpus) {
gpus.push({ gpus.push({
deviceName: name, deviceName: name,
usage: Math.round(utilization * 100) / 100, 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: 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 usage = parseInt(usageData.trim(), 10) || 0;
const memoryUsed = parseInt(memUsedData.trim(), 10) || 0; const memoryUsed = Math.round(
const memoryTotal = parseInt(memTotalData.trim(), 10) || 0; (parseInt(memUsedData.trim(), 10) || 0) / (1024 * 1024 * 1024)
);
const memoryTotal = Math.round(
(parseInt(memTotalData.trim(), 10) || 0) / (1024 * 1024 * 1024)
);
gpus.push({ gpus.push({
deviceName: 'GPU', deviceName: 'GPU',