From 100e8ea9dbf749f0b3fc8108ad272a21a7c9e08d Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Tue, 1 Apr 2025 14:49:33 -0700 Subject: [PATCH] Show system info --- src/ketr-chat/src/App.tsx | 11 ++++++++--- src/server.py | 9 +++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/ketr-chat/src/App.tsx b/src/ketr-chat/src/App.tsx index 8f1aa23..52b16f7 100644 --- a/src/ketr-chat/src/App.tsx +++ b/src/ketr-chat/src/App.tsx @@ -78,9 +78,14 @@ interface ControlsParams { reset: (types: ("rags" | "tools" | "history" | "system-prompt")[], message: string) => Promise }; +type GPUInfo = { + name: string, + memory: number, + discrete: boolean +} type SystemInfo = { - "Installed RAM (GB)": string, - "Graphics Cards": string[], + "Installed RAM": string, + "Graphics Card": GPUInfo[], "CPU": string }; @@ -101,7 +106,7 @@ const SystemInfoComponent: React.FC<{ systemInfo: SystemInfo }> = ({ systemInfo return v.map((card, index) => (
{convertToSymbols(k)} {index}
-
{convertToSymbols(card)}
+
{convertToSymbols(card.name)} {card.discrete ? `w/ ${Math.round(card.memory / (1024 * 1024 * 1024))}GB RAM` : "(integrated)"}
)); } diff --git a/src/server.py b/src/server.py index 8548a86..8d8e9ab 100644 --- a/src/server.py +++ b/src/server.py @@ -16,6 +16,7 @@ import uuid import random import subprocess import re +import math def try_import(module_name, pip_name=None): try: @@ -71,7 +72,7 @@ def get_installed_ram(): meminfo = f.read() match = re.search(r'MemTotal:\s+(\d+)', meminfo) if match: - return f"{round(int(match.group(1)) / 1024**2, 2)}GB" # Convert KB to GB + return f"{math.floor(int(match.group(1)) / 1000**2)}GB" # Convert KB to GB except Exception as e: return f"Error retrieving RAM: {e}" @@ -84,7 +85,7 @@ def get_graphics_cards(): # Clean up the output (remove leading/trailing whitespace and newlines) output = result.stdout.strip() for index in range(len(output.splitlines())): - result = subprocess.run(['ze-monitor', f'--device {index+1} --info'], capture_output=True, text=True, check=True) + result = subprocess.run(['ze-monitor', '--device', f'{index+1}', '--info'], capture_output=True, text=True, check=True) gpu_info = result.stdout.strip().splitlines() gpu = { "discrete": True, # Assume it's discrete initially @@ -103,7 +104,7 @@ def get_graphics_cards(): gpu["memory"] = match.group(1) continue - match = re.match(r'^\s*Is integrated with host: Yes"', line) + match = re.match(r'^.*Is integrated with host: Yes.*', line) if match: gpu["discrete"] = False continue @@ -125,7 +126,7 @@ def get_cpu_info(): def system_info(model): return { - "Installed RAM": get_installed_ram(), + "System RAM": get_installed_ram(), "Graphics Card": get_graphics_cards(), "CPU": get_cpu_info(), "LLM Model": model