gpu-detector
Cross-platform GPU detection library for Python. Detects NVIDIA, AMD, Intel, Apple, and other GPUs on Linux, Windows, and macOS. Detects VRAM where the OS exposes it.
Most existing Python GPU detection tools are thin wrappers around nvidia-smi and only work for NVIDIA GPUs. gpu-detector was built to fill that gap: it detects all GPUs in a system, regardless of vendor, using the best available method on each platform.
Usage
from gpu_detector import detect, GPUInfo
gpus: list[GPUInfo] = detect()
for gpu in gpus:
print(gpu)
Or from the command line:
gpu-detector
GPUInfo dataclass
Each detected GPU is returned as a GPUInfo instance with the following fields:
| Field | Type | Description |
|---|---|---|
name |
str |
GPU name as reported by the system (e.g. "NVIDIA GeForce RTX 4090") |
vendor |
str | None |
Canonical vendor name: "NVIDIA", "AMD", "Intel", "Apple", "Matrox", "ASPEED", "VIA", "Moore Threads", "Zhaoxin", "VMware", "Red Hat", "QEMU/Bochs", or "VirtualBox" |
memory_mb |
int | None |
Dedicated VRAM in megabytes. Populated for all vendors where the OS exposes it; None for integrated GPUs with shared memory. |
driver_version |
str | None |
Driver version string, if available. |
device_id |
str | None |
PCI device ID (e.g. "10de:2620"), PNP device ID (Windows), or platform-specific identifier. |
source |
str | None |
Detection method that produced this entry (e.g. "lspci:-nn", "nvidia-smi", "powershell:Get-CimInstance Win32_VideoController"). |
__str__ output
print(gpu)
# → "NVIDIA GeForce RTX 4090 (NVIDIA) 24576 MB"
Supported vendors
Physical GPUs
| Vendor | PCI IDs |
|---|---|
| NVIDIA | 0x10de |
| AMD / ATI | 0x1002, 0x1022 |
| Intel | 0x8086 |
| Apple | 0x106b |
| Matrox | 0x102b |
| ASPEED | 0x1a03 |
| VIA | 0x1106 |
| Moore Threads | 0x1ed5 |
| Zhaoxin | 0x1d17 |
Virtual GPUs
| Vendor | PCI IDs |
|---|---|
| VMware SVGA | 0x15ad |
| Red Hat virtio-gpu | 0x1af4 |
| QEMU / Bochs | 0x1234 |
| VirtualBox | 0x80ee |
Detection methods by platform
Linux
lspci -nn— primary detection; identifies GPUs by PCI class./sys/class/drm— fallback whenlspciis unavailable.nvidia-smi— enriches NVIDIA entries with VRAM, driver version, and accurate names.- DRM sysfs VRAM — reads
/sys/class/drm/card*/device/mem_info_vram_totalfor AMD (amdgpu) and Intel Arc (xe/i915) VRAM.
Windows
- PowerShell (
Get-CimInstance Win32_VideoController) — primary; returns name, AdapterRAM, driver version, and PNP device ID for all vendors. - WMIC — fallback using the same WMI class.
macOS
system_profiler -json— primary; returns model, VRAM, vendor, and device ID.system_profiler(plain text) — fallback parsing of the text output.
Contributing
Pull requests are welcome! Whether it's adding support for a new vendor, improving detection on a specific platform, or fixing a bug, contributions of all sizes are appreciated.
Accuracy
This library is developed with limited access to operating systems and GPU hardware. Detection results may not be accurate for all configurations. If you encounter incorrect or missing information on your system, please open an issue with your GPU model, OS, and the output you received. It helps improve detection for everyone.
Release files for gpu-detector 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gpu_detector-1.0.0.tar.gz | 16.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gpu_detector-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.2 kB
Release files / gpu_detector-1.0.0.tar.gz
| Download URL | gpu_detector-1.0.0.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ce8b41c62c30d10efe25d7598663870dcb15326d397f8aeaedf14243db0e5728
|
|
BLAKE2b-256 checksum How to use checksums |
ac926e72d50e6ba451fe89c2675baf51d345ff5c76c284c037f99e1641302bbd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / gpu_detector-1.0.0-py3-none-any.whl
| Download URL | gpu_detector-1.0.0-py3-none-any.whl |
|---|---|
| Size | 12.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
51743d356c4545ece4db0db2528d6727e6863aa356b5721c394005c792ca05a6
|
|
BLAKE2b-256 checksum How to use checksums |
9be9ce8ee6b73b6ce5ed356eda8d7176ec28be4ae34b7bba736f3a09063a54da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|