{"id":9994,"library":"nvgpu","title":"NVIDIA GPU Tools","description":"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.","status":"active","version":"0.10.0","language":"en","source_language":"en","source_url":"https://github.com/rossumai/nvgpu","tags":["GPU","NVIDIA","monitoring","utilities","hardware"],"install":[{"cmd":"pip install nvgpu","lang":"bash","label":"Install nvgpu"}],"dependencies":[{"reason":"Core dependency for interacting with NVIDIA Management Library (NVML) to access GPU data.","package":"pynvml"}],"imports":[{"symbol":"nvgpu","correct":"import nvgpu"},{"symbol":"list_gpus","correct":"import nvgpu\ngpus = nvgpu.list_gpus()"},{"symbol":"gpu_info","correct":"import nvgpu\ninfo = nvgpu.gpu_info(gpu_id=0)"}],"quickstart":{"code":"import nvgpu\nimport os\n\n# Check if NVIDIA GPU and drivers are likely available\n# This is a basic check, actual NVML errors will still occur if setup is bad\nif os.path.exists('/dev/nvidia0') or os.environ.get('CUDA_VISIBLE_DEVICES') is not None:\n    try:\n        # Get a list of all GPUs and their basic info\n        gpus = nvgpu.list_gpus()\n        print(\"Detected GPUs:\")\n        if gpus:\n            for gpu_id, gpu_data in gpus.items():\n                print(f\"  GPU {gpu_id}:\")\n                for key, value in gpu_data.items():\n                    print(f\"    {key}: {value}\")\n\n            # Get detailed info for a specific GPU (e.g., the first one)\n            first_gpu_id = list(gpus.keys())[0]\n            detailed_info = nvgpu.gpu_info(gpu_id=first_gpu_id)\n            print(f\"\\nDetailed info for GPU {first_gpu_id}:\")\n            for key, value in detailed_info.items():\n                print(f\"  {key}: {value}\")\n        else:\n            print(\"No NVIDIA GPUs detected or NVML could not be initialized.\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n        print(\"Please ensure NVIDIA drivers are installed and nvidia-smi works.\")\nelse:\n    print(\"No NVIDIA GPUs detected or environment not configured for GPUs. Skipping nvgpu operations.\")\n    print(\"Ensure NVIDIA drivers are installed and CUDA_VISIBLE_DEVICES is set if in a restricted environment.\")","lang":"python","description":"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."},"warnings":[{"fix":"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.","message":"nvgpu relies on the NVIDIA Management Library (NVML), which in turn requires NVIDIA GPU drivers to be correctly installed and the `nvidia-smi` utility to be functional. If drivers are missing, corrupted, or not properly initialized, nvgpu functions will fail with NVML errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"nvgpu explicitly pins its `pynvml` dependency to a specific version (e.g., `pynvml==11.5.0` for nvgpu 0.10.0). Installing an incompatible or significantly different `pynvml` version in the same Python environment might lead to conflicts or unexpected behavior, even if `pip` handles the primary dependency correctly.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Install the package using pip: `pip install nvgpu`.","cause":"The `nvgpu` library has not been installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'nvgpu'"},{"fix":"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.","cause":"The NVIDIA driver is not loaded, or the NVIDIA Management Library (NVML) cannot be accessed. This typically means no NVIDIA GPU is detected, drivers are not installed, are corrupted, or the `nvidia-smi` service is not running.","error":"pynvml.nvml.NVMLError_DriverNotLoaded: Driver Not Loaded"},{"fix":"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).","cause":"The NVML shared library (e.g., `libnvidia-ml.so` on Linux, `nvml.dll` on Windows) cannot be located by `pynvml`. This often happens in environments without proper `LD_LIBRARY_PATH` configuration or if drivers are partially installed.","error":"NVMLError: NVML Shared Library Not Found"}]}