You need to log GPU utilization and VRAM statistics programmatically within a custom PyTorch training script to trigger automatic garbage collection when memory thresholds are exceeded. Which tool provides a native Python API for GPU querying in addition to its interactive terminal-based monitoring interface?
Select an answer to reveal the explanation.
Short Explanation
The nvitop tool isn’t just an interactive terminal monitor for GPUs; it also gives you a native Python API. You can import it into a custom PyTorch training script, query GPU utilization and VRAM stats programmatically, and trigger cleanup or garbage collection when memory thresholds are exceeded.
Full Explanation
The correct answer is nvitop. While nvitop is widely recognized for its interactive CLI monitor (similar to htop for GPUs), it is also distributed as a Python package containing a robust, developer-friendly Python API. This allows machine learning engineers to import nvitop into their training pipelines, query GPU telemetry (utilization, temperature, memory allocation, and process details) programmatically, and implement custom logic (like VRAM-based logging or dynamic batch size adjustments to prevent out-of-memory errors). - The gpustat option is a command-line tool built on top of nvidia-ml-py, but it does not provide an interactive console UI or a dedicated, high-level Python API suite comparable to nvitop. - The HWMonitor option is a general Windows hardware utility, not a programmable CLI or API tool for Linux-based deep learning environments. - The nvidia-settings option is a display configuration GUI for desktop workstations and lacks programmatic interface capabilities for model-training pipelines.