Skip to content

Commit

Permalink
chore: add back GPU information to system monitoring bar
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan committed Aug 12, 2024
1 parent fdab8af commit 3122d13
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
6 changes: 6 additions & 0 deletions core/src/types/events/resource.event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ export interface ResourceStatus {
cpu: {
usage: number
}
gpus: GpuInfo[]
}

export interface UsedMemInfo {
total: number
used: number
}

export interface GpuInfo {
name: string | undefined
vram: UsedMemInfo
}
2 changes: 1 addition & 1 deletion electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"request": "^2.88.2",
"request-progress": "^3.0.0",
"@kirillvakalov/nut-tree__nut-js": "4.2.1-2",
"cortexso": "v0.5.0-40"
"cortexso": "v0.5.0-43"
},
"devDependencies": {
"@types/js-yaml": "4.0.9",
Expand Down
13 changes: 7 additions & 6 deletions web/containers/Layout/BottomPanel/SystemMonitor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const SystemMonitor: React.FC = () => {
const [usedRam, setUsedRam] = useAtom(usedRamAtom)
const [totalRam, setTotalRam] = useAtom(totalRamAtom)
const [cpuUsage, setCpuUsage] = useAtom(cpuUsageAtom)
const gpus = useAtomValue(gpusAtom)
const [gpus, setGpus] = useAtom(gpusAtom)

const [showFullScreen, setShowFullScreen] = useState(false)
const [showSystemMonitorPanel, setShowSystemMonitorPanel] = useAtom(
Expand Down Expand Up @@ -63,13 +63,14 @@ const SystemMonitor: React.FC = () => {
setUsedRam(resourceEvent.mem.used)
setTotalRam(resourceEvent.mem.total)
setCpuUsage(resourceEvent.cpu.usage)
setGpus(resourceEvent.gpus?.filter(gpu => gpu.name && gpu.vram.used && gpu.vram.total) ?? [])

Check failure on line 66 in web/containers/Layout/BottomPanel/SystemMonitor/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-macos

Replace `resourceEvent.gpus?.filter(gpu·=>·gpu.name·&&·gpu.vram.used·&&·gpu.vram.total)·??·[]` with `⏎············resourceEvent.gpus?.filter(⏎··············(gpu)·=>·gpu.name·&&·gpu.vram.used·&&·gpu.vram.total⏎············)·??·[]⏎··········`

Check failure on line 66 in web/containers/Layout/BottomPanel/SystemMonitor/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-windows-pr

Replace `resourceEvent.gpus?.filter(gpu·=>·gpu.name·&&·gpu.vram.used·&&·gpu.vram.total)·??·[]` with `␍⏎············resourceEvent.gpus?.filter(␍⏎··············(gpu)·=>·gpu.name·&&·gpu.vram.used·&&·gpu.vram.total␍⏎············)·??·[]␍⏎··········`

Check failure on line 66 in web/containers/Layout/BottomPanel/SystemMonitor/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

Replace `resourceEvent.gpus?.filter(gpu·=>·gpu.name·&&·gpu.vram.used·&&·gpu.vram.total)·??·[]` with `⏎············resourceEvent.gpus?.filter(⏎··············(gpu)·=>·gpu.name·&&·gpu.vram.used·&&·gpu.vram.total⏎············)·??·[]⏎··········`
} catch (err) {
console.error(err)
}
},
signal: abortControllerRef.current.signal,
})
}, [host, setTotalRam, setUsedRam, setCpuUsage])
}, [host, setTotalRam, setUsedRam, setCpuUsage, setGpus])

const unregister = useCallback(() => {
if (!abortControllerRef.current) return
Expand Down Expand Up @@ -195,8 +196,8 @@ const SystemMonitor: React.FC = () => {
<div className="flex gap-x-2">
<div className="">
<span>
{gpu.memoryTotal - gpu.memoryFree}/
{gpu.memoryTotal}
{gpu.vram.used}/

Check failure on line 199 in web/containers/Layout/BottomPanel/SystemMonitor/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-macos

Delete `⏎······························`

Check failure on line 199 in web/containers/Layout/BottomPanel/SystemMonitor/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-windows-pr

Delete `␍⏎······························`

Check failure on line 199 in web/containers/Layout/BottomPanel/SystemMonitor/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

Delete `⏎······························`
{gpu.vram.total}
</span>
<span> MB</span>
</div>
Expand All @@ -205,12 +206,12 @@ const SystemMonitor: React.FC = () => {

<div className="flex items-center gap-x-4">
<Progress
value={gpu.utilization}
value={Math.round(gpu.vram.used / Math.max(gpu.vram.total, 1) * 100)}

Check failure on line 209 in web/containers/Layout/BottomPanel/SystemMonitor/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-macos

Replace `gpu.vram.used·/·Math.max(gpu.vram.total,·1)·*·100` with `⏎····························(gpu.vram.used·/·Math.max(gpu.vram.total,·1))·*·100⏎··························`

Check failure on line 209 in web/containers/Layout/BottomPanel/SystemMonitor/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-windows-pr

Replace `gpu.vram.used·/·Math.max(gpu.vram.total,·1)·*·100` with `␍⏎····························(gpu.vram.used·/·Math.max(gpu.vram.total,·1))·*·100␍⏎··························`

Check failure on line 209 in web/containers/Layout/BottomPanel/SystemMonitor/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

Replace `gpu.vram.used·/·Math.max(gpu.vram.total,·1)·*·100` with `⏎····························(gpu.vram.used·/·Math.max(gpu.vram.total,·1))·*·100⏎··························`
className="w-full"
size="small"
/>
<span className="flex-shrink-0 ">
{gpu.utilization}%
{Math.round(gpu.vram.used / Math.max(gpu.vram.total, 1) * 100)}%

Check failure on line 214 in web/containers/Layout/BottomPanel/SystemMonitor/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-macos

Replace `gpu.vram.used·/·Math.max(gpu.vram.total,·1)·*·100)}` with `⏎····························(gpu.vram.used·/·Math.max(gpu.vram.total,·1))·*·100⏎··························)}⏎··························`

Check failure on line 214 in web/containers/Layout/BottomPanel/SystemMonitor/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-windows-pr

Replace `gpu.vram.used·/·Math.max(gpu.vram.total,·1)·*·100)}` with `␍⏎····························(gpu.vram.used·/·Math.max(gpu.vram.total,·1))·*·100␍⏎··························)}␍⏎··························`

Check failure on line 214 in web/containers/Layout/BottomPanel/SystemMonitor/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

Replace `gpu.vram.used·/·Math.max(gpu.vram.total,·1)·*·100)}` with `⏎····························(gpu.vram.used·/·Math.max(gpu.vram.total,·1))·*·100⏎··························)}⏎··························`
</span>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion web/helpers/atoms/SystemBar.atom.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { GpuInfo } from '@janhq/core/.'
import { atom } from 'jotai'

export const totalRamAtom = atom<number>(0)
export const usedRamAtom = atom<number>(0)

export const cpuUsageAtom = atom<number>(0)

export const gpusAtom = atom<Record<string, never>[]>([])
export const gpusAtom = atom<GpuInfo[]>([])

export const nvidiaTotalVramAtom = atom<number>(0)
export const availableVramAtom = atom<number>(0)
Expand Down

0 comments on commit 3122d13

Please sign in to comment.