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.2.tar.gz (35.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.4.2-cp314-cp314t-musllinux_1_2_x86_64.whl (52.1 kB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

gpuq-1.4.2-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (50.1 kB view details)

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

gpuq-1.4.2-cp314-cp314t-macosx_11_0_arm64.whl (26.9 kB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

gpuq-1.4.2-cp314-cp314-musllinux_1_2_x86_64.whl (51.5 kB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

gpuq-1.4.2-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (49.4 kB view details)

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

gpuq-1.4.2-cp314-cp314-macosx_11_0_arm64.whl (26.8 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

gpuq-1.4.2-cp313-cp313-musllinux_1_2_x86_64.whl (51.1 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

gpuq-1.4.2-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (49.4 kB view details)

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

gpuq-1.4.2-cp313-cp313-macosx_11_0_arm64.whl (26.8 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

gpuq-1.4.2-cp312-cp312-musllinux_1_2_x86_64.whl (50.9 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

gpuq-1.4.2-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (49.3 kB view details)

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

gpuq-1.4.2-cp312-cp312-macosx_11_0_arm64.whl (26.8 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

gpuq-1.4.2-cp311-cp311-musllinux_1_2_x86_64.whl (50.9 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

gpuq-1.4.2-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (49.1 kB view details)

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

gpuq-1.4.2-cp311-cp311-macosx_11_0_arm64.whl (26.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

gpuq-1.4.2-cp310-cp310-musllinux_1_2_x86_64.whl (50.2 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

gpuq-1.4.2-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (48.9 kB view details)

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

gpuq-1.4.2-cp310-cp310-macosx_11_0_arm64.whl (26.8 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: gpuq-1.4.2.tar.gz
  • Upload date:
  • Size: 35.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.4.2.tar.gz
Algorithm Hash digest
SHA256 671f3e0416ebc898df3b0716b56c435616a6ac3dceb5756c4083a4ab70052515
MD5 5bc56968e6ad6aa3cf0ca043a0e20e0f
BLAKE2b-256 05b87b9f4ec9bda0b1c4de803bb2855783337a7a8973a7c77df379e93e215f13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.2-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ceb1bbf03a2e6e290aa2fd54ef2e4f45e344913c294feb7b303046027ab83427
MD5 f3b31903d2151e1c61f51b6518b40485
BLAKE2b-256 d3151da09360b5c65b8254eabc5df3774bdb3817bde9bb677a55c724368e70cd

See more details on using hashes here.

File details

Details for the file gpuq-1.4.2-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.2-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 5f49ec20a07c6b5401396f7bc84a380e112de715c15074078f2d99b6084d1a31
MD5 7960dd9100bb7927ad311a91f76de3d0
BLAKE2b-256 fe07a327ca401ca1f605333b78d630e3ae2ba505ba1d34382d493c33c26ddb0b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.2-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 57d0106844cde39018a75b535cc1550efbf9671cd301a6f5a29e1a7a4ad0f551
MD5 aa4112b3cfd81d004d15b7f498c54e61
BLAKE2b-256 785847bac29734460d2cebcfd98aa00ebcebeeec863bd49cc8288db63ee8be1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.2-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b8ce15c3e247fd16bf51079721f473ab0bcf23d5a0a846998ce9567560e24a58
MD5 dcf2046f553cb4bbcf680dea064c64cc
BLAKE2b-256 9e848f86078019cf68c25c9382aca3f4286473793682663c509fd91325147ced

See more details on using hashes here.

File details

Details for the file gpuq-1.4.2-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.2-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 4b526c220ff44ff07e0c6dbbcdf0ff561b17c4cc1332f2465f3b3cc215c4a6ee
MD5 fe6230b9d5196b3a0574854a609025e6
BLAKE2b-256 f24b1283863a5e28c75e0b7881c0a9d122d54f5ca5c81d16de6889d3c694b3a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.2-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bcc0f80ca59500e391c27b1cc59a1e2b61edc7cd4494511b4e9ed197123483f3
MD5 c5a8a8504ec0138b511ce3c3ea6d80f7
BLAKE2b-256 4b1c744fe9836b60cc7b59f74de44547d790568e8977ab8b3980f662d9fe727f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.2-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 45b3b8fa176ac4ad78de6e23fc70902e6e3a2823b243fee462602a26c77149e2
MD5 bb34ca73cb741ddf051052742a885ca4
BLAKE2b-256 5024f8e166ece822df1c098db8a752eaae17004eeb4202161a80c1a00c2bcadf

See more details on using hashes here.

File details

Details for the file gpuq-1.4.2-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.2-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 66a9537a758576e5c74edec2d112d1dc390ff079b46a33cd3e3e845291473579
MD5 cf861b59e8fe1c0c37a85252abb1acb9
BLAKE2b-256 d040480a6d647912acd1df2044495d33ec5518990b7b28f25c30a0ff3e9c310e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bf8539a9dc862c54b32b732dc16a2a7b8ff4bf4f5d925609b059909fb576d898
MD5 86a79230f13a242e35d97331d7c1940d
BLAKE2b-256 328383600b5bafd12670bc6aec5ebe64ca07cb77528847788eb1de5c09d1a1d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.2-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 af65597ff26e42491476e38a687c6c50355a9833b207367c8e02326c9809ec99
MD5 d639f425e716c8ab00aa17dc045cfb5a
BLAKE2b-256 605c6cb5c432d610c35e0fa664c36841b8bb2fcd1f50ddcae7d15621e98ab206

See more details on using hashes here.

File details

Details for the file gpuq-1.4.2-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.2-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 5f4da5436d6eb9807cc493f4e4f21a24854825cd781e302bd5de0bd31f128d73
MD5 5c908a50a0bd73b2420ffddddf061663
BLAKE2b-256 5f9e5f9dc78b2498bb3cc749e910167c338fe2cf71eb8fc86074009cec451eae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cfcffb0818e489f02a4cd8eba75c77b066e0dcc202f07b4c934af775337fdced
MD5 4c98cd4de359b1add85006ed3ca6f74c
BLAKE2b-256 27a96182eccf92130122aca73fafeb1749d2def55c20d624dce948ba0f04ebf4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.2-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 791a5864566716d2b7f3f5146d0a93345c0f8f41173b5eb98bec319947190d2a
MD5 1b79e789f8556b5f73f09b1ccf9801ff
BLAKE2b-256 cabef265092c078c37711d756c6657eff6ba9895d9b361b37e4b4f51f47de098

See more details on using hashes here.

File details

Details for the file gpuq-1.4.2-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.2-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 90d7f01dce6d94a3fd78b5620591ad14ded5b28bd2baa01fedf1f539b669181a
MD5 e3c0000b92b545cdd2b80c98912bc277
BLAKE2b-256 0aaccb6b02a1959213f29aeca8e8dc97c2f3714a100c30909eea4aca7455e53b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f501040d1d2c4e9318cc726ae41c56b8da4474e3ed5ffd90e8809f490c941392
MD5 1dabbcb223530b9ea21b9d20edfe0668
BLAKE2b-256 458c981d2efa921ab3c69f31b8e65d9c1ffe8c58394b3e029e0d79165743846d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.2-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8e87664554af14b5e866aef25b41953efa0f7ca931c80701255c556108904992
MD5 c352f47adb14b34e8fed36c20f11cb08
BLAKE2b-256 fb19df4b12364b49ad81b7402e1f591f8c44ed01fe925f7c916d96716d0f442f

See more details on using hashes here.

File details

Details for the file gpuq-1.4.2-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.2-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 b6d83b39bcd0874ce319044a3c6f5889d45e83684546d49053e8ad65bbd9ac1c
MD5 3fa61cbf2c2dbe623e504b9efff0149e
BLAKE2b-256 8f53467ceae6c96fc9c42b42e0953b9f8f00a50433c1b25b3c5d24c98f256fa4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4277bae6f01d0c81cf71aeaf0cbf9c3ffc5bd0aadc1bcc1c5145dea96c383e3f
MD5 b116d9dbadf3b6a1bf94ea2fbbc583c0
BLAKE2b-256 2264942d4eba2e00adab4f5fd958ac6891bb873f3a84e72a2e413b37eaea2410

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