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.0.tar.gz (35.8 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.0-cp314-cp314t-musllinux_1_2_x86_64.whl (55.2 kB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

gpuq-1.5.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (53.2 kB view details)

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

gpuq-1.5.0-cp314-cp314t-macosx_11_0_arm64.whl (27.7 kB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

gpuq-1.5.0-cp314-cp314-musllinux_1_2_x86_64.whl (54.6 kB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

gpuq-1.5.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (52.5 kB view details)

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

gpuq-1.5.0-cp314-cp314-macosx_11_0_arm64.whl (27.6 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

gpuq-1.5.0-cp313-cp313-musllinux_1_2_x86_64.whl (54.2 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

gpuq-1.5.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (52.4 kB view details)

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

gpuq-1.5.0-cp313-cp313-macosx_11_0_arm64.whl (27.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

gpuq-1.5.0-cp312-cp312-musllinux_1_2_x86_64.whl (54.0 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

gpuq-1.5.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (52.4 kB view details)

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

gpuq-1.5.0-cp312-cp312-macosx_11_0_arm64.whl (27.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

gpuq-1.5.0-cp311-cp311-musllinux_1_2_x86_64.whl (54.1 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

gpuq-1.5.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (52.1 kB view details)

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

gpuq-1.5.0-cp311-cp311-macosx_11_0_arm64.whl (27.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

gpuq-1.5.0-cp310-cp310-musllinux_1_2_x86_64.whl (53.4 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

gpuq-1.5.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (52.0 kB view details)

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

gpuq-1.5.0-cp310-cp310-macosx_11_0_arm64.whl (27.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: gpuq-1.5.0.tar.gz
  • Upload date:
  • Size: 35.8 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.0.tar.gz
Algorithm Hash digest
SHA256 03db61b91354fea84d74f2f2658ca188e54c27ab9344d3829934a0311e165a37
MD5 c9d1cdf5702e980b09e959c265b9b2a4
BLAKE2b-256 a979f6b55a524f111ac2c0c6353a586675b3d17a999babdb2ecb27d7c567c853

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.0-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 fdc3f7ceb51d771bcb0f611dbdee0714631b71c7c53ab91f9d7a19d8e44365d5
MD5 327136b97d32324ad2ba798831041eed
BLAKE2b-256 0f9e7c7c70eed709dc38b775e4918c85bc509814b09cf4bc292a917cec579f0f

See more details on using hashes here.

File details

Details for the file gpuq-1.5.0-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.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3ec76899069e7f65b7aa2ce182fa1c3e5a2a669d05859f1eef07507c58461583
MD5 9034adb46d04c853efb5a1f6b35fbd13
BLAKE2b-256 fc026d690952f073245dbf30d12c1b1d09ec2fdc64b8a9cdd0f2a746242d2949

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.0-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d0c6af3c47b1d16c474089a66544999613d149e0175fe0b84fc0a7c8b9d8e938
MD5 001564523f1771de05007124ec9ed8dd
BLAKE2b-256 b2346440d38e360f229db8790c13d420dfa74e7e1e4f018eea3f2506697aefec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.0-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f748a6aaf21297fe09151b9920c52784b3f9be1d04d57295909052ed1be6c280
MD5 5cde2ebb9c88a4f31118bae885079af6
BLAKE2b-256 07211a6d0341c97a6f21a8b388f56349e90a3371fb3697479f9ea96ca990d8e9

See more details on using hashes here.

File details

Details for the file gpuq-1.5.0-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.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 650ce5cfd0e1a29dd3d3ab61655750340a21153810c95b105d5a9b1b0b1e5e0f
MD5 67f4e5c709650c353bc80a6eec08aec3
BLAKE2b-256 edfe4492d341947db179ff348aed0dc837125787fec7d49779bf112f18cb1673

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e440d79bdd77aafc6557d75994970afe14116b50e9a9a9329d93e7d2a11788b0
MD5 fdd0bd57439a891569fc467bc4b0a30e
BLAKE2b-256 a5601f8832bdbe69915ec2b755c13d0f915d312e8424b33b35bfc2faf13d2c3a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.0-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e39e56f776e5546c883fb71bb00038e3b9cac5b2e1228a520fd2e928653aa10b
MD5 a808b274b90a7475759e52af1531f689
BLAKE2b-256 9afe806289d1e3a8b026aa4d721bc07eb337798c06f396b5baca1c7152db7f6f

See more details on using hashes here.

File details

Details for the file gpuq-1.5.0-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.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d0d4ef4b52399b9b4add1c2bc595ad3ab3f8e897c756a2cbc43b47b9285430af
MD5 5905cd8749f5fbbe50a340eb1f52d12c
BLAKE2b-256 b9dc69edd4142428252063b6637f55da839861f1d1832802c10cf5a8d59ca4d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2c47ba8dab003291f5f95ea610dc5a957f6e431134913640d23b013fff2bc1a0
MD5 c80ec30d205db5c2d5b0f76632b01f3d
BLAKE2b-256 fc9c058e1fa5183f4a0291adf9bbf7dff99fce03c9ba0f1f77c3b179ff8b4b77

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 3e80c57fc730167cf2e064a8decc80fd20e882bf8e7434bbf2ad72b18b55b11d
MD5 0a7192a61bd9587a02ad9730f2ddd09b
BLAKE2b-256 5c22f20eee0e2ebd6acb489112813c8907d20df5d6f1d2bc1978aff7a0cd7fb1

See more details on using hashes here.

File details

Details for the file gpuq-1.5.0-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.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bd482bf7d64541726781c9fd76f745b3cbd1dc13407e6d777f1324196bca0d80
MD5 26190307875e1857ea9abb88f8182bd8
BLAKE2b-256 a2063b7cd7a9d01c6240ff5a0b7bb60c4a43b91a938f6600fcbb264c40622684

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ad7389d72bdf682bc22c2f73bda4e06e23b335a1c48f7829d27bc524cfd5ee0c
MD5 412eefc271590dd6f668e9f4a2db859f
BLAKE2b-256 6c46d88c2854437787f9331161621d13ca6ad27b97a3c178c2a638b41ac1282a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.0-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8acd4cb0bfeee8e8976dc4eea9d42aafe64f2b47efd117a10935b7274caefe46
MD5 7bdbd2d3734746f6ce2151858078babd
BLAKE2b-256 2a0bf56fc0f6b57a0913977e8ecfe52e23dd65eed96e81ba107858edaa26d4d7

See more details on using hashes here.

File details

Details for the file gpuq-1.5.0-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.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4260ba5dcff32886f2197a4b8621d7ab5570433cae063b159fb8702f32df0fbc
MD5 faa51bcfa2dc5fd7125c567d6b0cb2be
BLAKE2b-256 133191644785ab77e4f0597ba57e244a7b4a42140e923b106b4ebd231fc2efc9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0fa6aefbf0b9db7d040254b9cb93a38f3ee742ca6863afa624f6fda7af5d5b7c
MD5 f9f9b126de95ca1f94f20d37dea91b04
BLAKE2b-256 c7c7d5809aedb02f2371311adbb1e671c8ef80847f4abdcfa73f8b272c45117f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.0-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 012559c3eb6b42a4b9483a6fec75f53c931d46426d4fd4cf15bbd0229b55ea94
MD5 c54bda217dba3db9dd92d6d82af6860a
BLAKE2b-256 8101d5734b83c23585b9f020cf1b11c7f3131a48d6729a33a9382eb14a526011

See more details on using hashes here.

File details

Details for the file gpuq-1.5.0-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.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3355e0086816bf1a6ee4c28af4a4cab35fa997e1d8d9b63125dbd2ce2376b743
MD5 a988edef075a8a246f300f8275eeb611
BLAKE2b-256 0f9b6e7acb664c754fc02d8e69102950e51fbb9a39969d9068b75ca4344169e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c9bae1242a54d6be284cefbb5b9699e18372a24912d151fb777e09ff42ab800f
MD5 1cbcadea031560c0e74dce00d108ad1b
BLAKE2b-256 ea09562e7a7703dcc29e99635a029fcb3dd3e0ea46a68bcb8c1e12282536090f

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