skillfed

py3nvml

Python 3 Bindings for the NVIDIA Management Library

py3nvml v0.2.7 192.5K downloads/30d#9,861 on PyPI250
Permissive license BSD Abandoned released

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 py3nvml

uv

uv add py3nvml

poetry

poetry add py3nvml

Installing 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

Development Status :: 3 - AlphaIntended Audience :: DevelopersIntended Audience :: System AdministratorsLicense :: OSI Approved :: BSD LicenseOperating System :: Microsoft :: WindowsOperating System :: POSIX :: LinuxProgramming Language :: PythonProgramming Language :: Python :: 3.5Topic :: Software Development :: Libraries :: Python ModulesTopic :: System :: HardwareTopic :: System :: Systems Administration

Tags

nvidia gpu query pythoncuda visible devices managementgpu memory monitoringnvml python bindingsshared gpu server allocationgpu process detectionnvidia driver info python
gpu-managementnvidia-hardwareabandoned

More Python Modules packages

Further reading