Cross-platform GPU detection library
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gpu_detector-1.0.0.tar.gz.
File metadata
- Download URL: gpu_detector-1.0.0.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce8b41c62c30d10efe25d7598663870dcb15326d397f8aeaedf14243db0e5728
|
|
| MD5 |
04ead7ac66ee787b01a1e7b3833beb1a
|
|
| BLAKE2b-256 |
ac926e72d50e6ba451fe89c2675baf51d345ff5c76c284c037f99e1641302bbd
|
File details
Details for the file gpu_detector-1.0.0-py3-none-any.whl.
File metadata
- Download URL: gpu_detector-1.0.0-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51743d356c4545ece4db0db2528d6727e6863aa356b5721c394005c792ca05a6
|
|
| MD5 |
435b4502c73af24aac8ba32a4df72803
|
|
| BLAKE2b-256 |
9be9ce8ee6b73b6ce5ed356eda8d7176ec28be4ae34b7bba736f3a09063a54da
|