nvgpu is a Python library providing tools for interacting with NVIDIA GPUs, offering functionalities to list GPUs, retrieve detailed information, and monitor their status. It acts as a user-friendly wrapper around the lower-level pynvml library. The current version is 0.10.0, and it maintains an active development pace with several releases per year.
pip install nvgpuVerified import paths — ran on the pinned version, not inferred.
This quickstart example demonstrates how to use nvgpu to list all detected NVIDIA GPUs and retrieve detailed information for a specific GPU. It includes basic error handling for environments without NVIDIA GPUs or proper driver setup.
Ensure your NVIDIA GPU drivers are installed, up-to-date, and `nvidia-smi` runs successfully from your terminal. Rebooting your system can sometimes resolve driver initialization issues.
Prefer to install `nvgpu` in a clean virtual environment to avoid dependency conflicts. If you encounter issues, check `pip show pynvml` to ensure its version matches what `nvgpu` expects. You may need to reinstall `nvgpu` in a fresh environment.
Install the package using pip: `pip install nvgpu`.
Ensure NVIDIA drivers are correctly installed and up-to-date for your GPU. Verify `nvidia-smi` works from your terminal. Rebooting the system can sometimes resolve driver issues.
Confirm NVIDIA drivers are fully installed. Ensure the directory containing the NVML shared library is in your system's library path. For Docker, ensure the container has access to GPU devices and drivers (e.g., using `--gpus all` or proper NVIDIA Container Toolkit setup).