{"id":4656,"library":"nvidia-ml-py3","title":"NVIDIA Management Library Python Bindings (Python 3 Port)","description":"The `nvidia-ml-py3` library provides Python 3 compatible bindings to the NVIDIA Management Library (NVML), a C-based API for monitoring and managing NVIDIA GPUs. It allows Python applications to query GPU statistics, health, and other operational data. This specific package is an older port for Python 3 from the original `nvidia-ml-py` and is currently at version 7.352.0. The project's GitHub repository indicates it is archived and recommends migrating to the actively maintained `nvidia-ml-py` package.","status":"abandoned","version":"7.352.0","language":"en","source_language":"en","source_url":"https://github.com/nicolargo/nvidia-ml-py3","tags":["NVIDIA","GPU","monitoring","system-management","NVML"],"install":[{"cmd":"pip install nvidia-ml-py3","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"This library is a wrapper around the NVIDIA Management Library (NVML) C-based API, which requires properly installed and up-to-date NVIDIA GPU drivers to function.","package":"NVIDIA GPU Drivers","optional":false},{"reason":"NVML relies on the CUDA toolkit; a misconfigured CUDA installation can lead to initialization failures.","package":"NVIDIA CUDA Toolkit","optional":false}],"imports":[{"note":"The package name on PyPI is `nvidia-ml-py3`, but the internal module to import is `pynvml`.","wrong":"import nvidia_ml_py3","symbol":"pynvml","correct":"import pynvml"}],"quickstart":{"code":"import pynvml\n\ntry:\n    pynvml.nvmlInit()\n    print(f\"Driver Version: {pynvml.nvmlSystemGetDriverVersion()}\")\n    device_count = pynvml.nvmlDeviceGetCount()\n    print(f\"Found {device_count} GPU device(s).\")\n    for i in range(device_count):\n        handle = pynvml.nvmlDeviceGetHandleByIndex(i)\n        name = pynvml.nvmlDeviceGetName(handle)\n        temperature = pynvml.nvmlDeviceGetTemperature(handle, pynvml.NVML_TEMPERATURE_GPU)\n        memory_info = pynvml.nvmlDeviceGetMemoryInfo(handle)\n        print(f\"  Device {i}: {name.decode('utf-8') if isinstance(name, bytes) else name}\")\n        print(f\"    Temperature: {temperature}°C\")\n        print(f\"    Memory: {memory_info.used >> 20}MiB / {memory_info.total >> 20}MiB (Used/Total)\")\n\nexcept pynvml.NVMLError as error:\n    print(f\"NVML Error: {error}\")\n    print(\"Common causes: Missing/outdated NVIDIA drivers, permission issues, or no GPUs found.\")\nfinally:\n    try:\n        pynvml.nvmlShutdown()\n    except pynvml.NVMLError as error:\n        print(f\"NVML Shutdown Error: {error}\")","lang":"python","description":"Initializes the NVML library, retrieves the system's NVIDIA driver version, iterates through detected GPUs to display their name, temperature, and memory usage, and then properly shuts down the NVML library. Includes error handling for common NVML issues."},"warnings":[{"fix":"Migrate to `pip install nvidia-ml-py` and update imports accordingly (e.g., `from pynvml import *` will still work, but check for any API changes).","message":"The `nvidia-ml-py3` package is officially deprecated and its GitHub repository is archived. Users are strongly advised to switch to the actively maintained `nvidia-ml-py` package (note the lack of '3' in the name) for continued support and updates.","severity":"breaking","affected_versions":"All versions"},{"fix":"Ensure NVIDIA drivers are installed and compatible with your GPU and OS. Verify the GPU is recognized (e.g., `nvidia-smi` command-line tool). Grant necessary permissions if running as a restricted user. Reinstalling NVIDIA drivers or the NVML libraries might be necessary.","message":"NVML functionality critically depends on a correctly installed and up-to-date NVIDIA GPU driver. Issues like 'NVML not initialized' or 'NVMLError: Driver Not Loaded' typically indicate driver problems, missing driver files, or insufficient user permissions to access GPU devices.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always wrap NVML calls within a `try...finally` block to ensure `nvmlInit()` and `nvmlShutdown()` are called reliably, as shown in the quickstart example.","message":"It is essential to call `pynvml.nvmlInit()` before any other NVML functions and `pynvml.nvmlShutdown()` when your application finishes. Failing to call `nvmlInit()` will result in `NVMLError: Uninitialized`, and not calling `nvmlShutdown()` can lead to resource leaks.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Pin the library version (e.g., `nvidia-ml-py==X.Y.Z`) that is compatible with your specific NVIDIA driver version. Refer to the `nvidia-ml-py` release history for compatibility notes.","message":"The underlying `nvidia-ml-py` (and thus `nvidia-ml-py3`) has historically introduced backward-incompatible API changes, particularly concerning data structures like `nvmlProcessInfo_t`. Newer versions might introduce fields (e.g., `gpuInstanceId`, `computeInstanceId`) that are incompatible with older NVIDIA drivers, causing crashes or incorrect data.","severity":"breaking","affected_versions":">=11.450.129 (of the underlying NVML API/nvidia-ml-py)"},{"fix":"Inspect the `pynvml.py` source for the exact constant definition if encountering type errors. If present, manually extract the integer value from the tuple or switch to a fixed version of the `nvidia-ml-py` library if available.","message":"Some constant definitions in `pynvml.py` (e.g., `NVML_P2P_CAPS_INDEX_READ`, `NVML_GRID_LICENSE_EXPIRY_` definitions) have been reported to contain extraneous commas, inadvertently turning them into tuples instead of integers. This can cause unexpected type errors if used directly.","severity":"gotcha","affected_versions":">=11.525.131 (of the underlying nvidia-ml-py)"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}