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 --strictchecking)
Compared to some existing alternatives, it has the following differences:
torch.cuda- not lightweight, also requires a different wheel for NVidia and HIPgputil- NVidia specific, also broken dependencies (as of 2025)gpuinfo- NVidia specific, brokenimport gpuinfo...gpuinfonv- NVidia specific, requires pynvmlpyamdgpuinfo- AMD specificigpu- 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_DEVICESand 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-smiorrocm-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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gpuq-1.5.2.tar.gz.
File metadata
- Download URL: gpuq-1.5.2.tar.gz
- Upload date:
- Size: 36.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0363dd7409ec2669dc81b33b9221e1033613826cd671314e9c000314b38f6999
|
|
| MD5 |
6560f5337aba647c384b8c0898bd7bc2
|
|
| BLAKE2b-256 |
e1fb3c5ace9ae3035a8e3d47e0b4ab14b79c06504aa8b36743f845bbdc904a13
|
File details
Details for the file gpuq-1.5.2-cp314-cp314t-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: gpuq-1.5.2-cp314-cp314t-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 56.0 kB
- Tags: CPython 3.14t, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a12556e7d16baf665bafe2cc4b40a369c46d9c3516e3b07b3cb47afa3dd9ceac
|
|
| MD5 |
60a25f620e1453a95c8e82e0eede969d
|
|
| BLAKE2b-256 |
734617dd017b51b3af681a48a72a9d613fecf47846d649b522747df511fe126b
|
File details
Details for the file gpuq-1.5.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: gpuq-1.5.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 56.0 kB
- Tags: CPython 3.14t, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ee95c106d6d609be164f36d1ce5dbb4994f3fe73f6525b1168ba765c8a2afbc
|
|
| MD5 |
e805b0c869269d771a1badcaf9d57d78
|
|
| BLAKE2b-256 |
b09568dc101324d10a95f512341e069658dbfad26281691d7578a5573e5d7b02
|
File details
Details for the file gpuq-1.5.2-cp314-cp314t-macosx_11_0_arm64.whl.
File metadata
- Download URL: gpuq-1.5.2-cp314-cp314t-macosx_11_0_arm64.whl
- Upload date:
- Size: 28.0 kB
- Tags: CPython 3.14t, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a323f54fe3269d3b7e751e32e4c038d852a269a944cf6187a17960276259ce2
|
|
| MD5 |
b6589945d6f1d07d92d3fa75c97b8efd
|
|
| BLAKE2b-256 |
83d817bfd8df31c26a1e6de9aef71fda605297f9040fcc61edeeebe224e1e0b5
|
File details
Details for the file gpuq-1.5.2-cp314-cp314-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: gpuq-1.5.2-cp314-cp314-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 55.4 kB
- Tags: CPython 3.14, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
984dc62481b87fa2277231a0417a40b6d269a61a4d8e05b80a77d8c5340c627d
|
|
| MD5 |
b960cf3018bf955eb971be0db3f51e7a
|
|
| BLAKE2b-256 |
e8acb92abdcfb79db8e0e29be139ae41f2722e828da0123ded67a34545798049
|
File details
Details for the file gpuq-1.5.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: gpuq-1.5.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 55.3 kB
- Tags: CPython 3.14, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c120c1c91ada56ab2a875d42c8a8ecd4a9fed50f11287ddf9e3156773ff1e11
|
|
| MD5 |
4a40c377c8f13368aa7d22e75b591452
|
|
| BLAKE2b-256 |
86656dfe714e6dabe5ef1fec5df69e910d003b509b7ac3ee04e5df1269df0548
|
File details
Details for the file gpuq-1.5.2-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: gpuq-1.5.2-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 27.9 kB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10148fcfe0aaabe27faa748ec8f0db9f39e99a099e2885e0b6c81888a3ae9c9c
|
|
| MD5 |
d2d4b1f8357949217cab35ad643cf7c1
|
|
| BLAKE2b-256 |
b5358409ac423e844fe3448160c15ab2b4a76cccfe13339ecddcaeac7012d9fd
|
File details
Details for the file gpuq-1.5.2-cp313-cp313-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: gpuq-1.5.2-cp313-cp313-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 55.0 kB
- Tags: CPython 3.13, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
018be5e18a7a8fc358b7b49b8474b6d68ef1896c6919bf3a6653d0c00b5d9954
|
|
| MD5 |
e1c8e704287b22a3be5299cadd153ad2
|
|
| BLAKE2b-256 |
a662edc824b4388289899adb82834c464546ae61b06d02604ffc5cacfc318929
|
File details
Details for the file gpuq-1.5.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: gpuq-1.5.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 55.2 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca84bd5a712c2eb64ffcdd7797397c03b9ea8d6386dd5a39de143c844aa862b5
|
|
| MD5 |
6163db05e8886e331dc7a836455b9e0a
|
|
| BLAKE2b-256 |
d2fc21a029add023457f0999fc2e2ac5322c093cceb4bf1d1d68b5d839e8cf9f
|
File details
Details for the file gpuq-1.5.2-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: gpuq-1.5.2-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 27.9 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b679cb6b4cb55362cc706a407b57d38bc09ebe1f890d0a964b74c235027782b5
|
|
| MD5 |
88050009165ac9d7302ad6e4fc30880f
|
|
| BLAKE2b-256 |
dd3068cd33fe393c4305bb95fd4b8fa63b31625ef1fafc92bc2b53471fca1d70
|
File details
Details for the file gpuq-1.5.2-cp312-cp312-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: gpuq-1.5.2-cp312-cp312-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 54.8 kB
- Tags: CPython 3.12, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bafd909a84ee29906edc75edf81a030a7913f0431317cb89239d1fb5f7286fc4
|
|
| MD5 |
cb86497d7d5cd595f992f8010f7bb5ea
|
|
| BLAKE2b-256 |
4a2b1cd1afb59df57bb30afe94b32e039c135c91d1936781a148c97527e0b62d
|
File details
Details for the file gpuq-1.5.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: gpuq-1.5.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 55.1 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ef078ed43246317d6a7fb27833b5e3ffafe495df5fb8ecaff67b3fd68274aa8
|
|
| MD5 |
fc6ea4c97b1b46906ba834dd37540032
|
|
| BLAKE2b-256 |
e036e51c825e166e3cfbc76c1af851b50b3485e429315c265750ace003655ffb
|
File details
Details for the file gpuq-1.5.2-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: gpuq-1.5.2-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 27.9 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38b17e0a1535c4c2c00c45165a93518ab377297e4bff893e3051e979dcf88c5a
|
|
| MD5 |
5f6b66ce87dfd39340188f07dda5dc04
|
|
| BLAKE2b-256 |
2ef4c682d9e7e2f779b95d22d4557412c7f5b6eaafdf1d5656fbbcb52a0fb186
|
File details
Details for the file gpuq-1.5.2-cp311-cp311-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: gpuq-1.5.2-cp311-cp311-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 54.9 kB
- Tags: CPython 3.11, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94941602d732bd6f28f93590f392def685e1ea0e636c67d41a8875ee535a7768
|
|
| MD5 |
d3be89a9f60ca8bc48edeefd7547c757
|
|
| BLAKE2b-256 |
a9c65f8db12578f76f53be884fba0f4efe7e5a7230c869d99c83569bf86f208b
|
File details
Details for the file gpuq-1.5.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: gpuq-1.5.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 54.8 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3208e06961717bcd0ab55b903580efa528632bf69d776b7878f9cd041118d1b3
|
|
| MD5 |
9737bf0cb7c6549ffc4c72c761c4bb8d
|
|
| BLAKE2b-256 |
6efcbe3c1a04ec53ed715f77f07f47f0c673d7bc5bd4433dfc4fa28961b606b4
|
File details
Details for the file gpuq-1.5.2-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: gpuq-1.5.2-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 28.0 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f82184f030e847bf0c6fcd04f1ad99174d75227f893340561af8f531969e08c
|
|
| MD5 |
306122e025fb7b03d37574a86f9d9688
|
|
| BLAKE2b-256 |
f5c77f3a977a30af63516e28532aebafd977278b295d5ecd67947d4727cc477c
|
File details
Details for the file gpuq-1.5.2-cp310-cp310-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: gpuq-1.5.2-cp310-cp310-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 54.2 kB
- Tags: CPython 3.10, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
407f7545a97d3a90b761b007bf9063a50edc4a9a49ff80efdc4d7ad48ed72d7a
|
|
| MD5 |
74f672008c4a7f5688f09c4e73325246
|
|
| BLAKE2b-256 |
cc17afcd716280a46318eaa4de731acb5e60a832cffda657b266f74149e82168
|
File details
Details for the file gpuq-1.5.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: gpuq-1.5.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 54.6 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e6a209b156cb962104fba2cc792573a14e4ae288503f86b4118e2c02123a5e0
|
|
| MD5 |
b918c7dadd29ecc062e4b227d838adbd
|
|
| BLAKE2b-256 |
4320ee1718477081c591d21be1f29a265e136623ba118e5606d8373b15259513
|
File details
Details for the file gpuq-1.5.2-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: gpuq-1.5.2-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 28.0 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97e234b271447a7161056410cd98d82bc0baa2c803e143551f6f63ded074430f
|
|
| MD5 |
9541c38680cab5db4b1c6b157a007948
|
|
| BLAKE2b-256 |
74fc5404fbd0c3fafa36f187d6ed7b61f7f8f71a205d81d22834f33f79ae5098
|