Skip to main content

A multi-vendor GPU querying utility with minimal dependencies

Project description

gpuq - multi-vendor GPU querying utility with minimal dependencies

This small library is a direct answer to the lack of a lightweight, cross-compatible utility to query available GPUs - regardless of what vendor, distro, or overall environment one might be using.

In particular, the implementation meets the following requirements:

  • works with multiple downstream runtimes (currently supported: CUDA and HIP)
    • will also work if you have multiple present at the same time (do you really, though?)
  • no build- or install-time dependencies (including any python packages)
  • any runtime dependencies are soft - unless the user explicitly asks for the status/presence of a particular downstream runtime, most methods will fail silently
  • consequently, the package should install and run on pretty much any machine
    • your laptop does not have a GPU? -> the package will report 0 GPUs available (duh), no exceptions, linker errors, etc.
  • allows for easy mocking (for unit tests, etc.)
  • fully typed (conforms to mypy --strict checking)

Compared to some existing alternatives, it has the following differences:

  • torch.cuda - not lightweight, also requires a different wheel for NVidia and HIP
  • gputil - NVidia specific, also broken dependencies (as of 2025)
  • gpuinfo - NVidia specific, broken import gpuinfo...
  • gpuinfonv - NVidia specific, requires pynvml
  • pyamdgpuinfo - AMD specific
  • igpu - NVidia specific, broken installation (as of 2025)
  • and so on...

The primary functionality offered is:

  • check how many GPUs are available
  • query properties for each available device - will tell you some basic info about the provider (CUDA/HIP) and other info similar to cudaGetDeviceProperties
    • the returned list is not comprehensive, though
  • respects *_VISIBLE_DEVICES and provides mapping between local (visible) and global indices
    • NOTE: this temporarily modifies env variables and therefore is not thread-safe
  • if requested, lazily provides some runtime information about each GPU as well
    • in particular, PIDs of processes using the GPU will be returned
    • NOTE: this is currently done rather naively by parsing outputs of tools like nvidia-smi or rocm-smi
  • allows to check for runtime errors that might have occurred while trying to load

How it works:

The implementation will attempt to dynamically lazy-load libcudart.so and libamdhip64.so at runtime. For GPUs to be properly reported, the libraries have to be found by the dynamic linker at the moment any relevant function call is made for the first time. (If a library fails to load, loading will be retried every time a function call is made).

Examples

Install with:

pip install gpuq

Return the number of available GPUs:

import gpuq as G

print(G.count()) # this includes GPUs from all providers, disregarding *_VISIBLE_DEVICES
print(G.count(visible_only=True)) # only visible GPUs from all providers
print(G.count(provider=G.Provider.HIP, visible_only=True)) # only visible HIP devices
# etc.

Return a list of gpu properties:

import gpuq as G

for gpu in G.query(visible_only=True, provider=G.Provider.ANY):
    print(gpu.name)

# return all visible GPUs, raise an error if no CUDA devices are present
# (note: the required check if done against the global set, not the return set - see the docs)
gpus = G.query(visible_only=True, provider=G.Provider.ANY, required=G.Provider.CUDA)

Provide mapping between local and global GPU indices:

import gpuq as G

# assume a system with 8 GPUs and CUDA_VISIBLE_DEVICES=1,7
for gpu in G.query(): # by default return visible GPUs only
    print(gpu.index, gpu.system_index)

# should print:
# 0 1
# 1 7

for gpu in G.query(visible_only=False):
    print(gpu.index, gpu.system_index, gpu.is_visible)

# should print:
# None 0 False
# 0 1 True
# None 2 False
# None 3 False
# None 4 False
# None 5 False
# None 6 False
# 1 7 True

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gpuq-1.5.3.tar.gz (36.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

gpuq-1.5.3-cp314-cp314t-musllinux_1_2_x86_64.whl (56.0 kB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

gpuq-1.5.3-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (56.0 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

gpuq-1.5.3-cp314-cp314t-macosx_11_0_arm64.whl (28.1 kB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

gpuq-1.5.3-cp314-cp314-musllinux_1_2_x86_64.whl (55.4 kB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

gpuq-1.5.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (55.3 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

gpuq-1.5.3-cp314-cp314-macosx_11_0_arm64.whl (27.9 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

gpuq-1.5.3-cp313-cp313-musllinux_1_2_x86_64.whl (55.0 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

gpuq-1.5.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (55.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

gpuq-1.5.3-cp313-cp313-macosx_11_0_arm64.whl (27.9 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

gpuq-1.5.3-cp312-cp312-musllinux_1_2_x86_64.whl (54.8 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

gpuq-1.5.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (55.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

gpuq-1.5.3-cp312-cp312-macosx_11_0_arm64.whl (27.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

gpuq-1.5.3-cp311-cp311-musllinux_1_2_x86_64.whl (54.9 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

gpuq-1.5.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (54.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

gpuq-1.5.3-cp311-cp311-macosx_11_0_arm64.whl (27.9 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

gpuq-1.5.3-cp310-cp310-musllinux_1_2_x86_64.whl (54.2 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

gpuq-1.5.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (54.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

gpuq-1.5.3-cp310-cp310-macosx_11_0_arm64.whl (28.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file gpuq-1.5.3.tar.gz.

File metadata

  • Download URL: gpuq-1.5.3.tar.gz
  • Upload date:
  • Size: 36.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for gpuq-1.5.3.tar.gz
Algorithm Hash digest
SHA256 59382dea96ce96b26787c80eb1253e45059ca8846e3a5866b0302ddfc44eebe0
MD5 06244e88c283f64d26686232376c1c1c
BLAKE2b-256 e5ea00fed7c284ed581371136d017066e7944235be0376ec0fd8ff3d9a1bed07

See more details on using hashes here.

File details

Details for the file gpuq-1.5.3-cp314-cp314t-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for gpuq-1.5.3-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 95747a4a77fd21108ca5d2283060185a059d12159e1ebf3996f33cfaf3a2724b
MD5 870b65090dd8072fcbe9ae46933cfd08
BLAKE2b-256 daec6886fef86adaa6d2c5bc67e1c4f1857cd6804dca11c6012ee93ec8a41493

See more details on using hashes here.

File details

Details for the file gpuq-1.5.3-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gpuq-1.5.3-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 940696dd179094af02d2fe54deecdad290ef36e4831705cb26679a0601a5bf5b
MD5 d6e62e017dbafcf742458b4c20bf29e4
BLAKE2b-256 b204aab5580d5ecfc44744c36aaa475f420e822985854ca4f9d64c748bd83984

See more details on using hashes here.

File details

Details for the file gpuq-1.5.3-cp314-cp314t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gpuq-1.5.3-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2e3c0d3c15f27be2d8b3d9fd597e57906d93558f9e156b95bf032bea179b0471
MD5 cb17e3e987531545d40bd5189e6c4305
BLAKE2b-256 ea9693999f3dbb3295392cc5b837126d94387b863317449e29c3c109b8aa908f

See more details on using hashes here.

File details

Details for the file gpuq-1.5.3-cp314-cp314-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for gpuq-1.5.3-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 1a95aa44ffbec59a066698280c41aae49a32b1924f2dff1be5c1db0fb0979052
MD5 8e3312ae84430b1c3be330c3b536d1b4
BLAKE2b-256 1b0842d7fc7e079498bf40087bf69ebea7efc9434317679b92f1121b20cf62c6

See more details on using hashes here.

File details

Details for the file gpuq-1.5.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gpuq-1.5.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 036dcc71814036904e10d1eeeedd33ecc4159623fcc09c4e279170f674b61b03
MD5 899977b2bd1c84f9dd4d85307e079935
BLAKE2b-256 0d1d92e5af1c0aa43f2ce925b73daf39aab858923c1e7b057cbbee5f114889a5

See more details on using hashes here.

File details

Details for the file gpuq-1.5.3-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gpuq-1.5.3-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f41d7912b1cc8d18b96aa116d7f97b6e83b987ae4d51fc7cc4a09d0378bfc4c1
MD5 1e15a189f493188c4ce7a3b47e8d9427
BLAKE2b-256 2d0ead5fec22054472ddec986642478ffb794bb79afbc25c7c953b917bff1c0f

See more details on using hashes here.

File details

Details for the file gpuq-1.5.3-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for gpuq-1.5.3-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 476c1235816d27947ef6a5d3ca2f1e859deb88d47e403821d574c3b4f16b6ddd
MD5 48bd2c61d360a3eba9126e32eee74a05
BLAKE2b-256 dad059877a5a3b6064d6bc21056e6e32b743e0680dabdb653c4440c9cb2c218e

See more details on using hashes here.

File details

Details for the file gpuq-1.5.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gpuq-1.5.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c1e7421b9005d82bd4326404e7526e02711190bf782243261815a41c192ed102
MD5 154c801eaf6e1e6c7edd7de9af0ac1e2
BLAKE2b-256 5799e9c30c3d2af8715ec03730fec11c2a21a048aae6a847d0d281a11e9179a0

See more details on using hashes here.

File details

Details for the file gpuq-1.5.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gpuq-1.5.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e9e3995942a74f4adb9f1dec3a791ee944efec5aeae38274f869b2edab6ff6e6
MD5 7ee21b7e750554bddc2563bb49160618
BLAKE2b-256 a5135222621e029a47b7cf5c547bf5821c5c47761adc8afeed0a0c08b07b90a1

See more details on using hashes here.

File details

Details for the file gpuq-1.5.3-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for gpuq-1.5.3-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 fab64417b555bd0f36e852b0c00b0b05500c12dd28d9412bec71c4d69f2c910b
MD5 86fad9a6418963ab5db26ff8b56bde72
BLAKE2b-256 1146a9ca9babc4db16f2e1f4cadf353b4404369911f5f95035a549f49917658a

See more details on using hashes here.

File details

Details for the file gpuq-1.5.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gpuq-1.5.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f90d7589343b1e6ab434da7a23d2594a5177badd19a00f8dc8cdc4c03a82c55b
MD5 47a28256112de79259de0618aae19906
BLAKE2b-256 82482f10aebac605ef5a3fc57246d3553651a661c2bb24738115f3ae0fce1603

See more details on using hashes here.

File details

Details for the file gpuq-1.5.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gpuq-1.5.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 92aacef63c1fa2f76981ec4b1e44623bb5122e1995732e18c04b7038410e8649
MD5 32478905fc0c9955c46aa568c8e19d99
BLAKE2b-256 ce3b4da97d4f682def10f1984ce2ee9a8dbbd4ebba7b9c5711c9ee67071c63e8

See more details on using hashes here.

File details

Details for the file gpuq-1.5.3-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for gpuq-1.5.3-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 1927f290f3eb6ef4ea4c94859747390fdfc3fb124ec20060002ba3be32d86548
MD5 602554a355b96a04f8d2d770c4370f34
BLAKE2b-256 0ade5ca171083291bbefcd48b20aa7c5a40edce358266f3369bf42758eb4e8bb

See more details on using hashes here.

File details

Details for the file gpuq-1.5.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gpuq-1.5.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5396db7971535e2175e324bd1903ab4a3eb81c73509c0e252749faf9c45b575f
MD5 4ea041fcc323a5eb9ee4b9d45f3e2eb7
BLAKE2b-256 fe715ab13a7462beb1b7b5cc70312347ae114dbd071e523ce4839ce947d223f3

See more details on using hashes here.

File details

Details for the file gpuq-1.5.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gpuq-1.5.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e14a6144b02c0af5fb388073a9f9c1fa44eb8d4513268cd6ab792bee5aec5387
MD5 94c1730415993aff04ee3a08d6c5c913
BLAKE2b-256 b967282aaf5a01f8b093f0b038fdb2aba3e925440bf97dc0c3b5f0c7ca162ff4

See more details on using hashes here.

File details

Details for the file gpuq-1.5.3-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for gpuq-1.5.3-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e0afac0edf07fdafdf7e189c056ec12335f2908fe05ddf88b23d519c6e9ba3be
MD5 f618a1c82afa9a31c0fb2689ecd31042
BLAKE2b-256 650a50ea900ae1c4923cc83bb48b8423158b9c5a09ea1244bca83693b8819740

See more details on using hashes here.

File details

Details for the file gpuq-1.5.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gpuq-1.5.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fa37fe1e232536710ecd4abd505f8af164cc1385140862c8acfd7398fe7737a2
MD5 c80dc58a17fc22081b60c168a1f67ab9
BLAKE2b-256 10554759c3bac80be4526cf9a36327f3b2c006cbf4d7cf8187821d685fef81de

See more details on using hashes here.

File details

Details for the file gpuq-1.5.3-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gpuq-1.5.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 82ea7ddd7331a52d49fddb57d2a806dbc283d4d3348c6ea4e5b391a7a0ba0402
MD5 5124bbeb09698b24c1cbd9e49ade05d9
BLAKE2b-256 98f753cc0e14bc5b9327acc8b39d451f8f2f210dc23e7789478f724285e266f0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page