mirror of
https://github.com/lone-cloud/gerbil
synced 2026-06-03 09:33:10 -07:00
re-fix for linux
This commit is contained in:
parent
4178381242
commit
cc636250da
6 changed files with 19 additions and 13 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
', '
|
||||
|
|
|
|||
|
|
@ -444,7 +444,7 @@ export async function detectGPUMemory() {
|
|||
|
||||
memoryInfo.push({
|
||||
deviceName: formatDeviceName(gpu.deviceName),
|
||||
totalMemoryMB: vram,
|
||||
totalMemoryGB: vram,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()) {
|
||||
|
|
|
|||
2
src/types/hardware.d.ts
vendored
2
src/types/hardware.d.ts
vendored
|
|
@ -6,7 +6,7 @@ export interface CPUCapabilities {
|
|||
|
||||
export interface GPUMemoryInfo {
|
||||
deviceName: string;
|
||||
totalMemoryMB: number | null;
|
||||
totalMemoryGB: number | null;
|
||||
}
|
||||
|
||||
export interface GPUCapabilities {
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue