{"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.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install nvgpu"],"cli":null},"imports":["import nvgpu","import nvgpu\ngpus = nvgpu.list_gpus()","import nvgpu\ninfo = nvgpu.gpu_info(gpu_id=0)"],"auth":{"required":false,"env_vars":[]},"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}