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.4.0.tar.gz (34.9 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.4.0-cp314-cp314t-musllinux_1_2_x86_64.whl (51.7 kB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

gpuq-1.4.0-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (49.6 kB view details)

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

gpuq-1.4.0-cp314-cp314t-macosx_11_0_arm64.whl (26.7 kB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

gpuq-1.4.0-cp314-cp314-musllinux_1_2_x86_64.whl (51.1 kB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

gpuq-1.4.0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (49.0 kB view details)

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

gpuq-1.4.0-cp314-cp314-macosx_11_0_arm64.whl (26.5 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

gpuq-1.4.0-cp313-cp313-musllinux_1_2_x86_64.whl (50.6 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

gpuq-1.4.0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (48.9 kB view details)

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

gpuq-1.4.0-cp313-cp313-macosx_11_0_arm64.whl (26.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

gpuq-1.4.0-cp312-cp312-musllinux_1_2_x86_64.whl (50.5 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

gpuq-1.4.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (48.9 kB view details)

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

gpuq-1.4.0-cp312-cp312-macosx_11_0_arm64.whl (26.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

gpuq-1.4.0-cp311-cp311-musllinux_1_2_x86_64.whl (50.4 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

gpuq-1.4.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (48.6 kB view details)

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

gpuq-1.4.0-cp311-cp311-macosx_11_0_arm64.whl (26.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

gpuq-1.4.0-cp310-cp310-musllinux_1_2_x86_64.whl (49.8 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

gpuq-1.4.0-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (48.5 kB view details)

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

gpuq-1.4.0-cp310-cp310-macosx_11_0_arm64.whl (26.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for gpuq-1.4.0.tar.gz
Algorithm Hash digest
SHA256 fa9b6eeca041df3042bc9a21a8f6ee75336ad6d71188c3e79aa4df458517ab47
MD5 7f94d76b70c7e974e226efdb792af5a5
BLAKE2b-256 e992711825f177f241fdd6476893c9cd14cb5241d03ec0d22343f69e4fdf9112

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.0-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 a51fc5c4a099f7ce175dc9183eba46d126bbdae2245ea8b07c743c093ddbaf4a
MD5 4551b54db4ad563e368f7204ccad1ca4
BLAKE2b-256 0e3964eb1901e55b461c3d7ad7ebe6752594a10aee1a342c34e239ee21539646

See more details on using hashes here.

File details

Details for the file gpuq-1.4.0-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for gpuq-1.4.0-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 70c328f9c0f8fe7ca38e01a11fc6d1a57c1656a01e19ca571cdfaa8373f9fa31
MD5 010812de3674e2b45afa3a79d0a4c40c
BLAKE2b-256 ace0bdd40e825b397ea906b0a6a5b8d21e3ac92a38683564ba811f66097fea07

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.0-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 47c38b6eb38f5473a6769e6be97babe4ef44fe001c6bf4f98fd3f53df2b9191f
MD5 b76058531951f2a065b54f496bd1a3e9
BLAKE2b-256 134b5738bb12ed08e4ff9f06b1acc7b5e9836ec955729f14327e2c7b86b33481

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.0-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 68452d1439b22613fe8de5304e7e5f9b3058318acb9c41c581bd0fc591556c5c
MD5 c265947af0cd4c0933b8cda7f6cae440
BLAKE2b-256 721f4311a8bd7af2c014a9a7998888cb30221c3a3518eb520a5b57bf35894056

See more details on using hashes here.

File details

Details for the file gpuq-1.4.0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for gpuq-1.4.0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 6150f4388cad89064351431fad73057f9faf91421aaa13c0191ef37c26f7bd52
MD5 c5dd75825b70d9a05a143157f3177192
BLAKE2b-256 d0372e4d273f4c2d9bd206820c46dd5734b2d173ccd462d6345a08e6bb494603

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9c709d7c3891dc593bcb778de5bd35142428be7d03f9ff750aa1e1df492819cf
MD5 a9e2b262148def392146d197e1201c68
BLAKE2b-256 2eb608e95ad00fe9ce87b779867eb07dffc7658e826b9d4c4123160ac6026147

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.0-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9d41805594fdb97877a38e1a9f0988e1965c11f8795192e71af618d441221326
MD5 9a00f22c75c1679f96253b568d57881d
BLAKE2b-256 5afb54db5c5d485f4b93e314eeabbdb2479d45877bf4fb31ed5d0d61aba7a256

See more details on using hashes here.

File details

Details for the file gpuq-1.4.0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for gpuq-1.4.0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 eebac0a6273db15193813291042275eed805dfdd3fd3100f563734fd6bf7e71f
MD5 bae756b4a6bb78fcb34132af19e61227
BLAKE2b-256 3ce4307d851c56052616de7d6ac980fa7325f864c017a01843052442c97e9835

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 57678e846afc3ceb81e538aae470e2ec2e9f8eeb50869e20443373bc0342e082
MD5 52687432aef50fe3b78e6634b04d9144
BLAKE2b-256 f30bd69ea1ba07eab28c17f16e65d353f5bae5c0170e3a665b3f9bfa3331927b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 76bb59d22edb23875f3bf3b306a082a9f27927ed4066e9fdbe8245efe42d5b20
MD5 f7d4dca9de01a6494ba3066adba9cfac
BLAKE2b-256 1433de83c8c829adf45b581a154d94976e1fea9cd76b3d068558001588d6fe54

See more details on using hashes here.

File details

Details for the file gpuq-1.4.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for gpuq-1.4.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 6b7be1c7ff26db4d19746c2ff1310be306378cc644e91529a841e27dac2da2a5
MD5 b82eea462db89c00632aab575d116424
BLAKE2b-256 055ab175669b1020cb08c18a56b5ee4140d3b8152bb595afab2204a86bd1414c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0ea8c563cca8bd42f8473b3f1c637a6e296e0b1e19baa393caf266e94c37bf1e
MD5 6c4d4f4ca4a78af9d76ea5673159aff9
BLAKE2b-256 126243a1f167ab023481570dc96acc9a7d8c9290262a340f58967122f730b593

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.0-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ef5ec1234670d3d1e3f602f2a8abfdb02d2bdb3a0234b9bd0a28f7af60ebcb71
MD5 ea29041f97f942d6d4df5a2cca015f18
BLAKE2b-256 bcf22347232fe9c54322d4bce6c7801b2ba6a21497827e0149ab4602fa5aab16

See more details on using hashes here.

File details

Details for the file gpuq-1.4.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for gpuq-1.4.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 36a78e28378eae47241dfecf6635519e640dbcca99ded3a3b1cb5bd01b022014
MD5 6eb3086fc2e31f18622c1ac37cf4c405
BLAKE2b-256 72b4d40409ce9e12519d7a86ec7389c9f113b77c23dd2b100fa9869606c549fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9df9e0fb1279256e24ad7e6ff1b77da77c890d8d3a56c86b6718183abef90d92
MD5 b80037c7c2824ff9ed2cfe650e37d2ff
BLAKE2b-256 01d295f8066b5892e73fecef6452e1c4b343b81b601a55fb7595aa6e2f62e920

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.0-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 df81c84a68646e59a40faab6cd9ae2561d3bfcd643cc9fdca1feadbfe9803a4f
MD5 3d6d4473a2b10715239b5a78ee3d51c0
BLAKE2b-256 3ca9ce8a3e0f18523e84fe2931ebe21f372cf54d281f2359cf80f0a3cf7d6d31

See more details on using hashes here.

File details

Details for the file gpuq-1.4.0-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for gpuq-1.4.0-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 4a4f8da57856cdb78dc462da744c5847c35d7da78e64d59b4dc38d72453a6493
MD5 92ec65693b1b14b22fe77a346b31c213
BLAKE2b-256 ad6c21bfb5332656f39b9e4cf0a4e9bb3c8299e19fc2a15bdb11e91159b82f12

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6939a553af58338d99bbf51d40a483d4fd8914b2259184f55263f314e79b5c86
MD5 9b1ed4bc11ba53d40c2c326870524ca3
BLAKE2b-256 88cdd3500c03fa98200cd2caf202fe29aeff9cf17839e73411f09f919d927e50

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