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.1.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.1-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.1-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (50.0 kB view details)

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

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

Uploaded CPython 3.14tmacOS 11.0+ ARM64

gpuq-1.4.1-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.1-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.1-cp314-cp314-macosx_11_0_arm64.whl (26.8 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

gpuq-1.4.1-cp313-cp313-musllinux_1_2_x86_64.whl (51.0 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

gpuq-1.4.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (49.3 kB view details)

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

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

Uploaded CPython 3.13macOS 11.0+ ARM64

gpuq-1.4.1-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.1-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.1-cp312-cp312-macosx_11_0_arm64.whl (26.8 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

gpuq-1.4.1-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.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (49.0 kB view details)

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

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

Uploaded CPython 3.11macOS 11.0+ ARM64

gpuq-1.4.1-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.1-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.1-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.1.tar.gz.

File metadata

  • Download URL: gpuq-1.4.1.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.1.tar.gz
Algorithm Hash digest
SHA256 60e36bb2d20a420fe7f16df925e6e8ce87e5b3323f6af66b380f567f08cd629d
MD5 f6e673feed5e9ccef98341dc4d69a5f0
BLAKE2b-256 1a90ecb099cec7577988ef6e978fd7586f60d276536209f9e49ecb3b56c10834

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.1-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ede427cde5800a29cd22a6ceb8d8e0521336d7e842dff1602b422b6717f2ae8c
MD5 d2b3cd00259175dc564846b9d259fa35
BLAKE2b-256 f5d6dea89226340ec7733583b28e7b246ae30a253d3739f2bb4d6d9c331ad90c

See more details on using hashes here.

File details

Details for the file gpuq-1.4.1-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.1-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 96818f476f48513ec18823a4b35402fe26d6a2108bdabfab444bf339f4976f85
MD5 134e2de558962ad40229c32faac743b6
BLAKE2b-256 c338a0be02e950ce38bc52cbb2889772e19cd6bf1cd1cc4b04ca7da17803ca96

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.1-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d9d21c9e65a5961c23fc79acbc0908eebdd159cc28b6205162da150e951247c4
MD5 45607ca3808e031e9c9d8fec2462a17a
BLAKE2b-256 bf7bacdef39ef762be854025badd063580ace4f371fc76d6669d530e1a2b1a52

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.1-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2b8226e9f0cbdf04265c2760196bac027298f2af53a6d4953d8504199d717218
MD5 d1f06c5486916847c50d47e3d655cdc5
BLAKE2b-256 277d0646c134abf7f9890941bbb2a246e857d4aa403cd0497fa400475cac69da

See more details on using hashes here.

File details

Details for the file gpuq-1.4.1-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.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 490c41869d74fb69bf27e9d3a56e02e626924b357aff879f47a8bb7f72c10a76
MD5 26aedc3ad4e2c1fd1c0f856fb8d04cbb
BLAKE2b-256 67ebbec994620af4fb6bddb0cb041ca4ee05ac89f94bc0545c07897f7dcb5936

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1866eaec0194163ed33b7635d56e30704b3384cadb0cbf3be36f66eb18d2eef2
MD5 2c9b0be3ffe320a9d6779bf04f235192
BLAKE2b-256 87bcfb8e9cac66e6451164a34c4f9343debdc050e5cd156f487ded3203e886e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.1-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2de77cebf89229490af53a15ab7277e6c4af97412013b596eabfcb3a414436c5
MD5 4afb7702df4291912680372c45adb93e
BLAKE2b-256 ac9c2468c96e1b19d530f889fc92de7073f3ca1c9b0864d0902f2704b26997c4

See more details on using hashes here.

File details

Details for the file gpuq-1.4.1-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.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 84e536c878b11ede75f07090eab00f3a4f46eae158ee98ff0544b714d2f3e56e
MD5 2914a4231d70b74345da6c54c5291639
BLAKE2b-256 790f9c413cc8fc3d143506ca92979f652a67acf422ef7065febee64c9eda7009

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a40462cded85020042817990c20201c0dcd09b6fd3da4f4197967aec6774f50a
MD5 f88ebea3b5130e7a2938e226021e41da
BLAKE2b-256 9b056d3ddb0821ad80f627c09737c2d29b7ff523f81c61e07d200052a2ad9f67

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.1-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 7af212229de4ce59841d29250f6d419be371892bb946d433a22612712ecc1126
MD5 30bcab3e6f7559cf3a63f9c092cb2eaf
BLAKE2b-256 b6ccaa66a7853141b965f586431c27d3e70cee66f7df9ddce194aad747d68cd5

See more details on using hashes here.

File details

Details for the file gpuq-1.4.1-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.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 d65a1814248d4fea1cc275914e4b10e2aab3d17af96c9da5738c1b4ee593b87f
MD5 ce393d35496f9f94c43e73b740844930
BLAKE2b-256 fd9bdd6f56e10c0b244f4ab5f15f0d7de6e89d198ddca053fb06db63d4e494e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 233986b1776ba985810ed2030f7b65dd061cd37ff2a871219d62cf8e5312f042
MD5 37f48f38979c011a4a68768a2225efec
BLAKE2b-256 fa0f25f296e960b466465b2d6aadbf2199ebf22824dc3b3bf7ad11476492a29e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.1-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9cbd0a5dd74a9e448ca238c583085a0ff49c5c85f482e700c10fc9958ede4628
MD5 bbc06d102f8fc0be4ebe826e2601b1db
BLAKE2b-256 0b5a50cc4a4e66c38ce50fe925dce42f8164016836cc41013a9d6e358b7fc20b

See more details on using hashes here.

File details

Details for the file gpuq-1.4.1-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.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 66d9a9097d7aaf00143a0e96fcf4c08fd11e070ff0c4e398257b0262e6d9dd18
MD5 8d7b433ad9974919b78c1bdc9e38c0ed
BLAKE2b-256 cc17c1107ed61e4a16599362d80964dab9ea5298839781b1736d579723274a3b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eafa75344dd5d23299f7fc9042accfd70e023ce0464aa4911d3a71207847713f
MD5 567ffed12100cabc338ad3769874c284
BLAKE2b-256 03861c66041725adc1cf51d4d1175e49c7e726ee7845f60b3e71b9c543ae076a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.1-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5ab609ef05ffd684d0455ecbf0ae3d2b638fa19268259ffe9bf5054532aebf97
MD5 35d3025fb4df7054e7e2c9f83d5e4576
BLAKE2b-256 a5da7baa56522b96d58e7a50a7c50a3d8e0f0c16afd5c5139667ad49f3412f7c

See more details on using hashes here.

File details

Details for the file gpuq-1.4.1-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.1-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 3a2ba5805484d7cc941ea2dd973919fd31db1be95fb66c3aafa11b3768d075de
MD5 3695d97a501937b8083478a5af96cec9
BLAKE2b-256 17f49c11916859859515cb22962c12055c8a7d1a9ede0da561d8facd67b4ea74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gpuq-1.4.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1d4d2ab08d53367dc8a6ec22a442f5ddc6b380ae537cce9fb311154648a638bf
MD5 2fb3021aa8fb3e4cdd7c220002ca847b
BLAKE2b-256 6678b2d67d23faa1aed85b3fa040205fe33b610e460341e228bbaf038d01a497

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