Skip to content

KartikSawant/gpu-usage-alert

Repository files navigation

GPU Usage Alert

GPU Usage Alert is a Python script that continuously monitors GPU utilization and triggers a Twilio phone call if the GPU remains idle for a configurable duration. It helps you detect idle GPU resources and get instant phone notifications.

This script can run in the background via tmux or any terminal session.


Features

  • Monitors any GPU on the system using nvidia-smi.
  • Configurable GPU index, check interval, and idle threshold.
  • Sends a Twilio phone call when GPU usage is 0% for more than the configured duration.

Requirements

  • Python 3.8+
  • NVIDIA GPU with nvidia-smi installed
  • Twilio Python SDK (pip3 install twilio)
  • Dotenv (pip3 install python-dotenv)
  • Twilio account with a verified phone number

Installation

  1. Clone the repository:
git clone https://github.com/kartiksawant/gpu-usage-alert.git
cd gpu-usage-alert
  1. Install the required packages:
pip3 install -r requirements.txt

Usage

Basic Monitoring

python3 gpu_usage_alert.py --gpu 0 --interval 5 --threshold 60
  • --gpu : GPU index to monitor (default: 0)
  • --interval : Seconds between checks (default: 5)
  • --threshold : Idle duration in seconds before alert (default: 60)

Running in tmux

tmux new -s gpu_monitor
python3 gpu_usage_alert.py --gpu 0 --interval 5 --threshold 60
# Detach tmux session: Ctrl+B then D

Twilio Alerts Setup

To configure Twilio for phone call alerts, follow the detailed instructions in Twilio Setup README.

About

GPU Usage Alert: Monitor your GPU and get an instant Twilio call whenever it stays idle.

Resources

License

Stars

Watchers

Forks

Languages