Hardware API
Thehardware module detects system specifications including CPU, RAM, GPU hardware, and inference backends.
Core Types
SystemSpecs
The main struct containing all detected hardware information:
total_ram_gb- Total system RAM in gigabytesavailable_ram_gb- Currently available RAM (for model loading)total_cpu_cores- Number of logical CPU corescpu_name- CPU model name stringhas_gpu- Whether any GPU was detectedgpu_vram_gb- VRAM of primary GPU (per-card, not total)total_gpu_vram_gb- Total VRAM across all same-model GPUs (for multi-GPU inference)gpu_name- Primary GPU model namegpu_count- Number of same-model GPUs (for multi-GPU setups)unified_memory- Whether GPU and CPU share memory pool (Apple Silicon, AMD APUs)backend- Primary inference backend for the systemgpus- All detected GPUs (may span multiple vendors)
GpuBackend
The acceleration backend for inference:
GpuInfo
Information about a single detected GPU:
Functions
SystemSpecs::detect()
Detects system hardware specifications:
SystemSpecs::with_gpu_memory_override()
Override detected GPU VRAM (useful when detection fails):
vram_gb- VRAM amount in gigabytes
SystemSpecs::display()
Prints formatted system specifications:
parse_memory_size()
Parses human-readable memory sizes:
s- Size string (“32G”, “32GB”, “32000M”, etc.)
gpu_memory_bandwidth_gbps()
Get memory bandwidth for known GPU models:
name- GPU model name
is_running_in_wsl()
Detects whether running in WSL (Windows Subsystem for Linux):
GPU Detection Details
The hardware detection system uses platform-specific methods:NVIDIA GPUs
- nvidia-smi - Primary method via
--query-gpu=memory.total,name - sysfs - Fallback for containerized environments (
/sys/class/drm/card*/device) - Unified Memory Detection - Detects NVIDIA Grace Blackwell via
addressing_modefield
AMD GPUs
- rocm-smi - For systems with ROCm installed
- sysfs - For systems without ROCm (
/sys/class/drm/card*/device) - Unified APUs - Detects Ryzen AI MAX and AI 9/7/5 series with shared memory
Apple Silicon
- system_profiler SPDisplaysDataType - Detects M1/M2/M3/M4 series
- Unified memory: Reports total system RAM as VRAM (same memory pool)
Intel GPUs
- sysfs - Detects Arc GPUs via vendor ID 0x8086
- lspci - Fallback identification
Windows
- PowerShell -
Get-CimInstance Win32_VideoController - wmic - Fallback for older Windows versions
Multi-GPU Systems
For same-model multi-GPU setups:total_gpu_vram_gb field is used for fit scoring since llama.cpp and vLLM support tensor splitting across multiple GPUs.
Platform-Specific Notes
macOS
On newer macOS versions (Tahoe+),available_ram_gb uses vm_stat as a fallback when sysinfo fails.
Linux Containers
In containerized environments (Docker, Podman, Toolbx), GPU detection falls back to sysfs and usesflatpak-spawn --host lspci when needed.
WSL
WSL environments are detected viaWSL_INTEROP environment variable or /proc/version contents.