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.1.tar.gz (36.0 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.1-cp314-cp314t-musllinux_1_2_x86_64.whl (55.3 kB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

gpuq-1.5.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (53.3 kB view details)

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

gpuq-1.5.1-cp314-cp314t-macosx_11_0_arm64.whl (27.8 kB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

gpuq-1.5.1-cp314-cp314-musllinux_1_2_x86_64.whl (54.7 kB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

gpuq-1.5.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (52.6 kB view details)

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

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

Uploaded CPython 3.14macOS 11.0+ ARM64

gpuq-1.5.1-cp313-cp313-musllinux_1_2_x86_64.whl (54.3 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

gpuq-1.5.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (52.5 kB view details)

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

gpuq-1.5.1-cp313-cp313-macosx_11_0_arm64.whl (27.7 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

gpuq-1.5.1-cp312-cp312-musllinux_1_2_x86_64.whl (54.1 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

gpuq-1.5.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (52.5 kB view details)

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

gpuq-1.5.1-cp312-cp312-macosx_11_0_arm64.whl (27.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

gpuq-1.5.1-cp311-cp311-musllinux_1_2_x86_64.whl (54.2 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

gpuq-1.5.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (52.2 kB view details)

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

gpuq-1.5.1-cp311-cp311-macosx_11_0_arm64.whl (27.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

gpuq-1.5.1-cp310-cp310-musllinux_1_2_x86_64.whl (53.5 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

gpuq-1.5.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (52.1 kB view details)

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

gpuq-1.5.1-cp310-cp310-macosx_11_0_arm64.whl (27.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: gpuq-1.5.1.tar.gz
  • Upload date:
  • Size: 36.0 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.1.tar.gz
Algorithm Hash digest
SHA256 868cf58dd6826592b7dedef35e8d268083f792ed036b0cd7ead84bf009f0b5cb
MD5 ceb36e7aae9985f69530c697b63834e2
BLAKE2b-256 b8be509d53308a8fe04b6c8fce432cc92e722d2a4c978101dced4d0acc68c802

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.1-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ab4ed688892f7e7422fb3e0c25b6d3182cd2b29c3ebbdf289fee8b972a6747d3
MD5 1afdca0847f78b67c22bfc9cbc6a0c18
BLAKE2b-256 32d72fb6266fde16c899898986c79d36b04d082e69c326493b912034cc85fbb2

See more details on using hashes here.

File details

Details for the file gpuq-1.5.1-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.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 028d5d93419ba10fe7769bb00e98c310d56200463def8ba3596c5f085b0f7236
MD5 6cd14fcdfe2d28fffd07f8c0aeaab1d2
BLAKE2b-256 3183596b05a9fd17406b2488b93225186e7f4fcfce9c9c09a9dbe58c28a31351

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.1-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d291ffb4ef71151a8fbf79250d957a196ff08a2044285daf6a6f17b31098a9c6
MD5 b049534f98128d15b377eb566f8e3784
BLAKE2b-256 a08c89353726fec8fc43ccc5e3b0924d8ffbf79e8d85ff695d2666e08fe0c8f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.1-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f3d93b0bca722d15a2ae1b9ed942e91ad9421a36fbfad371305463fa5938401d
MD5 f2b7b3e803b2c65aa06e9fe50806f783
BLAKE2b-256 9718c700b56884bad22a7c876c962b1b97921515ac71f2c72f48407a0b92b611

See more details on using hashes here.

File details

Details for the file gpuq-1.5.1-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.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f182b116dc14b6399be5483e03215088812d3705e8015a1bb4ef674d38323415
MD5 6d301c3ab1109203a9825ade9c805550
BLAKE2b-256 572013e85b84173cfa58676f588d9ffde8e350720dd9269c623535f5fd6dba5b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0b3b6f2f61fc67b7960ae06c164a2daa0dbc5a377cb50a321b9ddd2b3a5b0a1e
MD5 d876a093bd14a23f19b154acdbb6d085
BLAKE2b-256 3d7910101e30754207cb8d3bbe4b0e28941dcd7ca2db40049dbed5408188a84a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.1-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e721a7b7562aaca96192b608e2b73745f3cd1a35ffdaf2b3674c66dea255d503
MD5 9a7d83b90539510658df0b05f9c38394
BLAKE2b-256 1161d7f69d466220da22fb67216ca2d417be9bd6b343f7d848f70d03d7c69c7b

See more details on using hashes here.

File details

Details for the file gpuq-1.5.1-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.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d76182df38a57fd909b3785cad4a1a4155d542244be59d9b9cf844c748471314
MD5 32fddbf14527d8eaa96aa02c768ef8ac
BLAKE2b-256 ed1722b5601c1b20f06a4d92016ef20032e03d30191c8ef4a231430eb95d06e2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a4cedbbc111781b8c747ca1f82076cb34b8f96453d2199d30f9631929356d4fa
MD5 eab5ceeec2dba88dd9277d310c34f4e2
BLAKE2b-256 c1995e93291077cd3bda47a35d20e059ead481055818cac94f205c14962c2209

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.1-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 37564bea60ad78aaafda7c867c6a523073d6a915160751e46049a1b59723af6d
MD5 cfc92767af5f82dedfd7dc9cdb8cf6d0
BLAKE2b-256 da319a2eb2720d08bf38ee4a17b29c526dc8f7dcc13d51d4d02cdd0c21bfbe27

See more details on using hashes here.

File details

Details for the file gpuq-1.5.1-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.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0766ef609054a74a07ef28d5b5914328e370993cda4693cdd2d55cb21f422944
MD5 1e3ea61923f131dac4e88ec9a0a5bcda
BLAKE2b-256 6c91d6815cb622c63473d469ac6ac0774240bce1553b69fea9019f45859d43a4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e1be073b98229720f39811c7b3e995a5b62b2a52b02513ba7a5f142f95ea9a3b
MD5 563e6219e0b42f3b1191b33940ca4372
BLAKE2b-256 619398c47e8e8ccd4164aef9cb4b973e2dd6a0efd22bb2095c85e85c52aa3338

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.1-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5e94ef15acb93a2b0d1ffb3c18ad5486f7a49e022db74306d35358b001ba5730
MD5 83d1786c7cf4f38d7c52987707ce6e3f
BLAKE2b-256 2cb0ac00e526c1e45cfdcb3e4d51f5d6c565453083b3878754ab5a1757fc1bd1

See more details on using hashes here.

File details

Details for the file gpuq-1.5.1-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.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 434087d04cf779f5b92245dff82185571bd70f0b6482bfdef03cc53c0bff6bf2
MD5 581c86b112e39468558efa12dffb0512
BLAKE2b-256 83f76a9f5a4716a7a571729176bb8f580bb845ce8bd9e5c75c12a644be3b1d22

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5f9021b66a3bfb02fe0a70a4bd750fa7654a07fc327d2261b4a4eaf2a62bf988
MD5 461bd67faab0fcc3a065faf08aa0ed0c
BLAKE2b-256 11da20acd2715e9709951f7e1f0c3c728334179623e10ce43bafb5afbcb6ca69

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.1-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 4ff515fb4e3d580a8e5491d72fbf87ac99fe2f477044e4d36aeba7dbd3bf7bff
MD5 e42f262fd77f0ef8a826e10cd092e61f
BLAKE2b-256 b6572bda3e9cb0d03bf3fcac05e6bfaa19ccdada8abbe00d5eec58303e3982bb

See more details on using hashes here.

File details

Details for the file gpuq-1.5.1-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.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 381441d001f2e06b63bddc8c68bf7c710dcaa54546c0126dbca16626ffaad0f3
MD5 ef2412efa2c890473be490f43bda080b
BLAKE2b-256 4e0bc14e192d1ef22b8feec86253a0a52973ef849c68e50845e37a991a98c382

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.5.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5784fb6162465fa622067d74c7daffe6bdf048706640cf564268da78fcf7d9d7
MD5 54afd025854ac29a8adafcc1cf90eda5
BLAKE2b-256 458ca832fc7d36116f62fdd5a74fe2e00559acc8d8cfc7da6b786994985a5890

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