py3nvml
Python 3 Bindings for the NVIDIA Management Library
What it is and what it does
py3nvml is a Python 3 port of NVIDIA's official python bindings to the NVIDIA Management Library (NVML), allowing you to query GPU state, driver info, memory usage, and running processes programmatically. It wraps the C NVML library and raises Python exceptions instead of returning error codes, making it more Pythonic than the original C interface.
Beyond basic NVML queries, the package includes utility functions for shared GPU server scenarios: grab_gpus() automatically sets CUDA_VISIBLE_DEVICES to allocate a specified number of free GPUs based on memory thresholds, get_free_gpus() detects which GPUs have no running processes, and a py3smi command-line tool provides formatted GPU status output. These utilities address the practical problem of preventing greedy frameworks from monopolizing all available GPUs.
Use it for:
- Automatically allocate N free GPUs to a job on a shared multi-GPU server without manual CUDA_VISIBLE_DEVICES configuration.
- Monitor GPU memory usage and process counts programmatically to implement custom GPU scheduling or load-balancing logic.
- Query driver version, GPU model names, and memory capacity at runtime to validate hardware requirements before launching compute jobs.
- Implement a health-check or monitoring script that detects hung GPU processes or memory leaks across a cluster of machines.
- Build a web dashboard or CLI tool that displays formatted GPU status with custom metrics or filtering.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides Python 3 bindings to query NVIDIA GPU state and manage GPU visibility for multi-GPU systems via the NVIDIA Management Library.
No—the package is abandoned (last release 2021-11-22, last commit 2022-04-14) and will not track NVIDIA driver or CUDA API changes. For new projects, use actively maintained alternatives. If you have legacy code already using py3nvml, it may still work on older systems, but do not adopt it for new development.
Install
py3nvml on PyPI
pip
pip install py3nvmluv
uv add py3nvmlpoetry
poetry add py3nvmlInstalling py3nvml
Before you install
Low install friction with a single lightweight dependency (xmltodict). However, the package is abandoned—last release was 2021-11-22 and last commit 2022-04-14, with no active maintenance or security updates.
License in practice
BSD license is permissive and imposes minimal restrictions; you can use, modify, and distribute the package freely with attribution.
Quickstart
pip install py3nvml
from py3nvml.py3nvml import *
nvmlInit()
print("Driver Version: {}".format(nvmlSystemGetDriverVersion()))
deviceCount = nvmlDeviceGetCount()
nvmlShutdown()
Requires NVIDIA GPU hardware and NVIDIA drivers installed; NVIDIA Management Library (libnvidia-ml.so or equivalent) must be accessible on the system.
Verify before relying
- Compatibility with NVIDIA driver versions and CUDA toolkits released after 2022-04-14.
- Whether xmltodict dependency is actually used at runtime or only for optional nvidia_smi module functionality.
- Support status for Python versions beyond 3.5 (classifiers list only 3.5 explicitly).
Package facts
| License | BSD (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — xmltodict |
| Maintenance | abandoned — 1,726 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 192,517/month — #9,861 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: py3nvml-0.2.7-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
nvidia-ml-py3Provides Python bindings to NVIDIA's Management…
permissive · top 15,000 on PyPI
nvidia-ml-pyPython wrapper around NVIDIA's Management…
permissive · top 5,000 on PyPI
GPUtilGPUtil queries NVIDIA GPU status and…
permissive · top 15,000 on PyPI
nvgpuQueries and monitors NVIDIA GPUs on a machine,…
permissive · top 15,000 on PyPI
nvitopInteractive terminal-based viewer for NVIDIA…
copyleft · top 15,000 on PyPI
gpustatDisplays real-time NVIDIA GPU status, memory…
permissive · top 5,000 on PyPI
pyrsmiProvides Python bindings to monitor and manage…
permissive · top 15,000 on PyPI
egl-probeDetects and enumerates available graphics…
unclear · top 15,000 on PyPI
cuequivariance-ops-cu12Loads CUDA kernels for equivariant neural…
unclear · top 15,000 on PyPI
nvidia-nvshmem-cu13NVSHMEM provides a global address space for GPU…
unclear · top 1,000 on PyPI