diff --git a/system_checks.py b/system_checks.py index dae7f91..90b26b8 100644 --- a/system_checks.py +++ b/system_checks.py @@ -185,4 +185,45 @@ def hardware() -> str: f"🧬 Arch: {uname.machine}", f"🐧 Kernel: {uname.release}", ] + gpu_lines = _gpu_info() + if gpu_lines: + lines.append("") + lines.extend(gpu_lines) return "\n".join(lines) + + +def _gpu_info() -> list[str]: + # 1) NVIDIA: use nvidia-smi if available for model + memory + smi = _cmd("nvidia-smi --query-gpu=name,memory.total,driver_version --format=csv,noheader") + if smi and "ERROR:" not in smi and "not found" not in smi.lower(): + lines = ["🎮 GPU (NVIDIA)"] + for line in smi.splitlines(): + parts = [p.strip() for p in line.split(",")] + if len(parts) >= 2: + name = parts[0] + mem = parts[1] + drv = parts[2] if len(parts) > 2 else "n/a" + lines.append(f"• {name} | {mem} | driver {drv}") + return lines + + # 2) Generic: lspci (VGA/3D/Display) + lspci = _cmd("lspci -mm | egrep -i 'vga|3d|display'") + if lspci and "ERROR:" not in lspci and "not found" not in lspci.lower(): + lines = ["🎮 GPU"] + for line in lspci.splitlines(): + # Format: "00:02.0" "VGA compatible controller" "Intel Corporation" "..." + parts = [p.strip().strip('"') for p in line.split('"') if p.strip()] + if len(parts) >= 4: + vendor = parts[2] + model = parts[3] + lines.append(f"• {vendor} {model}") + elif line.strip(): + lines.append(f"• {line.strip()}") + # Try AMD VRAM from sysfs if present + vram = _cmd("cat /sys/class/drm/card*/device/mem_info_vram_total 2>/dev/null | head -n 1") + if vram and vram.strip().isdigit(): + bytes_val = int(vram.strip()) + lines.append(f"• VRAM: {bytes_val / (1024**3):.2f} GiB") + return lines + + return []