A user-friendly wrapper for nvidia-smi, forked from pmav99's repository, with added support for fan speed and power draw monitoring. This tool is particularly useful in multi-GPU systems, allowing you to filter GPUs based on resource usage (e.g., selecting the least utilized GPU).
- Enhanced GPU Monitoring: Includes fan speed and power draw metrics.
- Resource-Based Filtering: Easily identify the least utilized GPU in your system.
- Flexible Usage: Use as a CLI tool or integrate it as a Python library.
Run the following commands to explore available options:
nvsmifs --help
nvsmifs ls --help
nvsmifs ps --helpYou can also use nvsmifs as a Python library for more advanced workflows:
import nvsmifs
gpus = nvsmifs.get_gpus()
available_gpus = nvsmifs.get_available_gpus()
gpu_processes = nvsmifs.get_gpu_processes()Here's a simple Python function to display detailed GPU information:
import nvsmifs
def gpu_info():
for gpu in nvsmifs.get_gpus():
if gpu.display_active == 'Enabled':
gpu_details = (
f"ID: {gpu.id}, Power: {gpu.power_draw}W, "
f"Name: {gpu.name}, Temp: {gpu.temperature}°C, "
f"Fan Speed: {gpu.fan_speed}%, Utilization: {gpu.gpu_util}%"
)
print(gpu_details)
gpu_info()Output example:
ID: 0, Power: 50W, Name: NVIDIA GTX 1080, Temp: 65°C, Fan Speed: 30%, Utilization: 20%
Ensure the following requirements are met before using nvsmifs:
- An NVIDIA GPU
nvidia-smiinstalled and accessible- Python 2.7 or 3.6+
The recommended installation method is via pipx. Install nvsmifs with:
pipx install nvsmifsThis creates a virtual environment in ~/.local/pipx/venvs/nvsmifs and adds the nvsmifs executable to ~/.local/bin.
Alternatively, install directly with pip:
pip install --user nvsmifsContributions are welcome! If you'd like to improve this project, please:
- Fork the repository.
- Create a feature branch.
- Submit a pull request with a clear description of your changes.
This project is licensed under the MIT License. See the LICENSE file for details.