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.4.tar.gz (36.4 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.4-cp314-cp314t-musllinux_1_2_x86_64.whl (56.1 kB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

gpuq-1.5.4-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.4-cp314-cp314t-macosx_11_0_arm64.whl (28.1 kB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

gpuq-1.5.4-cp314-cp314-musllinux_1_2_x86_64.whl (55.5 kB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

gpuq-1.5.4-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.4-cp314-cp314-macosx_11_0_arm64.whl (28.0 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

gpuq-1.5.4-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.4-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.4-cp313-cp313-macosx_11_0_arm64.whl (28.0 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

gpuq-1.5.4-cp312-cp312-musllinux_1_2_x86_64.whl (54.9 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

gpuq-1.5.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (55.2 kB view details)

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

gpuq-1.5.4-cp312-cp312-macosx_11_0_arm64.whl (28.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

gpuq-1.5.4-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.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (54.9 kB view details)

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

gpuq-1.5.4-cp311-cp311-macosx_11_0_arm64.whl (28.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

gpuq-1.5.4-cp310-cp310-musllinux_1_2_x86_64.whl (54.3 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

gpuq-1.5.4-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (54.7 kB view details)

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

gpuq-1.5.4-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.4.tar.gz.

File metadata

  • Download URL: gpuq-1.5.4.tar.gz
  • Upload date:
  • Size: 36.4 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.4.tar.gz
Algorithm Hash digest
SHA256 1791f3021238a1e2ae7498e22247d9bce2afa6545dd6081236d4e38ac8de1134
MD5 20aa03e4604cbfd526600e50cb039f0c
BLAKE2b-256 b67251b8a32843b21137c857be78c94e36f33035d7c0fad960c0edbdf0f52cb8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.4-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b2601ee4cb189f5023eea0e43fbd780b95cbb35f6d5701bd9fc5171a5ba6c443
MD5 48e4954d437fd359075c69f37ebfbb9b
BLAKE2b-256 5f41cf3afe22d064999564402c4f5172714df9a8db1088524e1cd3cfbad646af

See more details on using hashes here.

File details

Details for the file gpuq-1.5.4-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.4-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 10f4aa88da8b6013f86c8a1245aa8bd7689a9b662f20415f41b4eb47639db2ab
MD5 fb8bef9018df7b6014672e9ffaec1892
BLAKE2b-256 6830638cef12838de73222efd90ddffcb927506d8ee16b8b21dbf4d4f520f261

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.4-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0c36d14f2cc3678a71a406931ba7d218204947fc9d3e509e9f7f50fe2101b753
MD5 c16ec2846f869455b50aaec5c47da115
BLAKE2b-256 325d5b75d6d8d8921173c1266bfabd7885869a24e5bd8e29fac9aa44fa04a599

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.4-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5d30ee4bd3404336ecf95a940b1e81e7838f64a3275e5a7a71c4c3d9eb3fd66f
MD5 2e7f6058abdea208578a11222142ed5f
BLAKE2b-256 2d29456ddfd9abdbd365d32ca16a03d760aa9dcae9f39b8479182ec83bc76429

See more details on using hashes here.

File details

Details for the file gpuq-1.5.4-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.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 05127fc57076b8c6917296653bf483047d5248243e49f8e5bf4c226dfafc9d83
MD5 3b9fd8e5f631b99da455b670396ba7c7
BLAKE2b-256 ca8570832ada63e482c48b078dfb7877725217a070f13a9bf5395af2478e4362

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.4-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 09f193130856ebc3e43fd78d83e9289d5ff9352f600ed66cee811a13d3ae5f23
MD5 b8434b088b4f0b7e9a8465816f23473e
BLAKE2b-256 0a998edcb8262e39d0a918c2039ad71582960076db11e93d3cd1dd46645a82eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.4-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 0d136a92124d86771a2b01ce5000deeb75205f4e2fcd1bfb005438944f6506ef
MD5 cafc26f551432ce02d593536d97f61a9
BLAKE2b-256 462df2f28e68e335784458b722adabe4d514663e31e4a32aff75ca7d98738f6d

See more details on using hashes here.

File details

Details for the file gpuq-1.5.4-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.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bdb0062f5196b1272dba8030cbff874c4e28fa133048cf52b634b4bb87231429
MD5 a47df8a5ab7156d17879b470bba66ed7
BLAKE2b-256 fe0d3377c86af0e06b68d488d066047235253a6dcd78f602484ebc9a2aa3ddda

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 45f8a5ea292511d7613fad51e6538b02a7771620fe86eb0d60185b1664f0eb99
MD5 973dce1cc74f11071a7e78119c7e3a6d
BLAKE2b-256 240ab5681f888b805014b71363265911ff63e1de3d542c382295c736f145ddd2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.4-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 31cd29204d7ad910839296396976bc1e79c7a6b65f7e11a84f48a3116e427f4f
MD5 800f1dd93d851a9acb16fffd28ab1ca0
BLAKE2b-256 df936b91c536e9c5a83d87120e3b4e39ad298cbb7b2eb6b2b64a06e50e7e36a7

See more details on using hashes here.

File details

Details for the file gpuq-1.5.4-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.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f512239304d3885104aaf6d6ff93f5ec87dc515bed184a3ad4bbc9e22e193e52
MD5 6db7c5975744783773d59e5882ac16f2
BLAKE2b-256 dccfb5b5f5e63e08729a68fc90f741da912a637542b680bb20b0f72ac31ecf02

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 40e4d0648404b08843f79270d4d92e84da1893d074fa96857b1a1b9f0a8dd15b
MD5 f8e9425ebf7fce5b7ab60ad9e3a6f48f
BLAKE2b-256 356c0c55f549f3b5aa8ee5c39f803c2f97b239c8e98098f0973eceab67ec1871

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.4-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8ae75d02667ecdc35835d4b92d226b74bb841e8724eb53942110801534d47e48
MD5 09c0fe7c828907081e6aa73b5d22b447
BLAKE2b-256 01e30b3515257dcb91a157d8ea971a47f205331a317c04e951e405684b89478c

See more details on using hashes here.

File details

Details for the file gpuq-1.5.4-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.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 476d076a1faa3c193a479e70a6cc68ebfa98cddd3648783868de875f16b6474d
MD5 99ae973d57c9ce0a3c0653069bdbf67e
BLAKE2b-256 8da68748a44f4d0d4b8d501150087e0dad03c52b8f93e2cddf05d47669d95875

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 92f1d0b14e08016cb48a9ce600ab588e8cd0560c76c62af3e310a09ab9a24d3e
MD5 4bb8fc3c0f08bf88a3aa51d583e37b3e
BLAKE2b-256 8e4cd9da5fc2e49d64c7b381bc06316ff026be755cf7e681be1bdf99e20e777b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.4-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9140767272d4bbcb4829b13bd44437e0a0dae6a49ca376327771bad5416c054f
MD5 d6008b5181ce9d5389d50de3e6988367
BLAKE2b-256 0f0d90d0b4fc7335386657f82ab4c738347922608a28cd48697a0bba25b03c57

See more details on using hashes here.

File details

Details for the file gpuq-1.5.4-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.4-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8d32307a40e55b1815120d631d38c111da99d32b4c7e054e2ed19a951c2df3f5
MD5 1af976d31af35c54eb3985c3198074d3
BLAKE2b-256 9129c83c58dd3ced62801e8ad059bb3e421013b41cfe40ce7c44f546ef5e9849

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2194deace6435161ffd34503c0941994b62cb265dfb0d9c9dc7151c868d77511
MD5 873c41c9ff09727e52ffc99c2558109a
BLAKE2b-256 1a15136f272021e1954422a9edb53cba4be174edea84e8936472714b33e7d628

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