Skip to main content

gpu_list

This is a simple little utility to list GPUs and their VRAM amounts in Windows and Linux. The main reason I create this is because WMI doesn't list accurate VRAM information, and it's slow, and I hate WMI a lot. The Windows code uses no external libraries or tools. Linux code will use nvidia-smi if necessary.

How it works

In Windows, it enumerates the registry keys at SYSTEM\ControlSet001\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318} and gets the info from there. It relies on the existence of HardwareInformation.qwMemorySize keys, which were added sometime in Windows 10 I think. Maybe. So this probably won't work for older Windows. I purposely didn't add support for the 32 bit registry key because it's bunk.

Vendor and Device name are looked up in the included pci.ids file from https://pci-ids.ucw.cz/

In Linux, it's a bit tougher. First it checks sysfs files mem_info_vram_total and vram_total, and uses those if found. If any NVidia devices are found it will use nvidia-smi to get an accurate VRAM total. For everything else it will check the pcie BAR memory mapping and try to estimate the VRAM. It was very close for my Intel GPU, so I kept it in. Please report any inaccurate readings.

Installation

pip install gpu_list

Usage

If you just want some quick info printed out, run gpu_list from the console, you will get output that looks like this:

┌────────────────────────────────────────┬───────────┬─────────────────────────────┬───────────┬─────────┐
│                 vendor                 │ vendor_id │            device           │ device_id │ vram_gb │
├────────────────────────────────────────┼───────────┼─────────────────────────────┼───────────┼─────────┤
│           Intel Corporation            │    8086   │        DG2 [Arc A770]       │    56a0   │  17.05  │
│           NVIDIA Corporation           │    10de   │ GA102 [GeForce RTX 3090 Ti] │    2203   │  24.15  │
│ Advanced Micro Devices, Inc. [AMD/ATI] │    1002   │           Raphael           │    164e   │   0.07  │
└────────────────────────────────────────┴───────────┴─────────────────────────────┴───────────┴─────────┘

(vram_gb = bytes / 1e9)

However, this is mostly meant to be used from code. gpu_list exports one function: get_info. It returns a list of dicts, one dict per GPU found. Each dict has the following keys: vendor, vendor_id, device, device_id, and vram_gb

Here's some example code:

from gpu_list import get_info

infos = get_info()

if infos:
    for index, info in enumerate(infos):
        print(f"Info for GPU #{index+1}")
        print("-" * 50)
        print(f"vendor = {info["vendor"]}")
        print(f"vendor_id = {info["vendor_id"]}")
        print(f"device = {info["device"]}")
        print(f"device_id = {info["device_id"]}")
        print(f"vram_gb = {info["vram_gb"]}")
        print("-" * 50)
else:
    print("Error getting GPU list!")

Running that code produces something like this:

Info for GPU #1
--------------------------------------------------
vendor = Intel Corporation
vendor_id = 8086
device = DG2 [Arc A770]
device_id = 56a0
vram_gb = 17.05
--------------------------------------------------
Info for GPU #2
--------------------------------------------------
vendor = NVIDIA Corporation
vendor_id = 10de
device = GA102 [GeForce RTX 3090 Ti]
device_id = 2203
vram_gb = 24.15
--------------------------------------------------
Info for GPU #3
--------------------------------------------------
vendor = Advanced Micro Devices, Inc. [AMD/ATI]
vendor_id = 1002
device = Raphael
device_id = 164e
vram_gb = 0.07
--------------------------------------------------

Metadata

Release files for gpu-list 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gpu-list 0.1.0
File Size Uploaded Provenance Actions
gpu_list-0.1.0.tar.gz 357.8 kB Without provenance Details for gpu_list-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gpu-list 0.1.0
File Interpreter ABI Platform Actions
gpu_list-0.1.0-py3-none-any.whl Python 3 none any Details for gpu_list-0.1.0-py3-none-any.whl

Total release size: 718.2 kB

Release files / gpu_list-0.1.0.tar.gz

Download URL gpu_list-0.1.0.tar.gz
Size 357.8 kB
Tags Source
SHA-256 checksum
How to use checksums
89a551380d183ebb89d03d62dbcc38c65d6528fb372414067c5907c97d77dca6
BLAKE2b-256 checksum
How to use checksums
8e2c51df17986d8d988d3d216d8b2ba292d59ce3da25e7f1eaa2959d8fd64ed9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / gpu_list-0.1.0-py3-none-any.whl

Download URL gpu_list-0.1.0-py3-none-any.whl
Size 360.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e8269e78f51089628be82fa8e74893978206b9b9a6ff88447069737f60795167
BLAKE2b-256 checksum
How to use checksums
76050e12101da4d6f469d642efc55eeb02f22098a34846846362d128ec444128
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for gpu-list 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page