Introduction to gpustat
gpustat
is a lightweight, command-line utility designed to monitor and provide concise information about NVIDIA graphics cards in a system. It serves as a flexible alternative to the more comprehensive nvidia-smi
command, offering a more focused and easy-to-read overview of GPU statistics.
Key Features
- Compact Display: It shows essential stats like temperature, utilization, and memory usage in a compact format.
- Customizable Output: Users can customize the information displayed, such as user processes, specific command lines, power and fan statistics, and more.
- Compatibility: It supports NVIDIA graphics cards and requires NVIDIA drivers version 450.00 or higher for its newer versions. However, it doesn't currently support AMD GPUs.
- Python Compatibility: Works with Python versions as low as 2.7, with version-specific compatibility details available.
Installation
Installing gpustat
is straightforward through Python Package Index (PyPI):
pip install gpustat
If requiring the latest version from the master branch, it can be installed directly from the GitHub repository:
pip install git+https://github.com/wookayin/gpustat.git@master
In situations where a user lacks root privileges, gpustat
can also be installed in user space to ease the restrictions.
Requirements
To ensure smooth functioning, gpustat
necessitates the use of nvidia-ml-py
, the official NVIDIA Python binding for NVML, instead of pynvml
. Proper driver and library versions are crucial for compatibility.
Usage
To use gpustat
, simply run the following in the terminal:
gpustat
The tool comes with various options to tailor the output to the user’s preferences. Some of these include:
--color
: Forces colored output.--show-user
: Displays the username related to each process.--show-full-cmd
: Shows full command lines and CPU statistics.--show-power
: Offers power usage data.--watch
: Continuously refreshes the display at set intervals.--json
: Outputs the statistics in JSON format.
Tips for Effective Usage
- Enable
gpustat --debug
for diagnosing issues. - Use
gpustat --watch
to monitor GPU stats continuously. - Running the
nvidia-smi daemon
command can increase the query speed and reduce CPU load. - Set
CUDA_DEVICE_ORDER
toPCI_BUS_ID
in your environment for consistent GPU ID usage between CUDA andgpustat
.
Viewing Default Output
The typical default output is structured as follows:
[0] GeForce GTX Titan X | 77°C, 96 % | 11848 / 12287 MB | python/52046(11821M)
This illustrates information such as GPU index, temperature, utilization, memory usage, and running processes.
Conclusion
gpustat
is a handy utility for users requiring quick, summarized NVIDIA graphics hardware status on a command-line environment. Its ease of installation, customizable output, and compatibility with various Python versions make it a versatile tool for developers and engineers needing succinct GPU statistics.