Spaces:
Sleeping
Sleeping
Commit ·
8d5aa89
1
Parent(s): f99221e
firt commit
Browse files- README.md +70 -1
- app.py +19 -0
- requirements.txt +1 -0
README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
title: Gradio Gpu Monitor
|
| 3 |
emoji: 👀
|
| 4 |
colorFrom: indigo
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 6.8.0
|
| 8 |
app_file: app.py
|
|
@@ -11,4 +11,73 @@ license: apache-2.0
|
|
| 11 |
short_description: A GPU Monitor Component for Gradio UI
|
| 12 |
---
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 2 |
title: Gradio Gpu Monitor
|
| 3 |
emoji: 👀
|
| 4 |
colorFrom: indigo
|
| 5 |
+
colorTo: yellow
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 6.8.0
|
| 8 |
app_file: app.py
|
|
|
|
| 11 |
short_description: A GPU Monitor Component for Gradio UI
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# `gradio-gpu-monitor`
|
| 15 |
+
<img alt="Static Badge" src="https://img.shields.io/badge/version%20-%200.0.1%20-%20blue">
|
| 16 |
+
<a href="https://huggingface.co/spaces/elismasilva/gradio_gpu_monitor"><img src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Demo-blue"></a>
|
| 17 |
+
<span>💻 <a href='https://github.com/DEVAIEXP/gradio_component_gpumonitor'>Component GitHub Code</a></span>
|
| 18 |
+
|
| 19 |
+
Custom real-time GPU monitoring component for Gradio apps using `gr.HTML`. It polls `nvidia-smi` in the background and displays live statistics (VRAM, Temperature, Load, Power, and Clocks) in an elegant, responsive grid.
|
| 20 |
+
|
| 21 |
+
Perfect for AI training dashboards, LLM hosting interfaces, or any Gradio app where users need to keep an eye on hardware resource consumption.
|
| 22 |
+
|
| 23 |
+
Inspired by the GPU monitoring widget from the Ostris [AI-Toolkit](https://github.com/ostris/ai-toolkit)
|
| 24 |
+
|
| 25 |
+
## Features and Key Characteristics
|
| 26 |
+
|
| 27 |
+
- **Real-time targeted updates** with zero DOM flickering or flashing.
|
| 28 |
+
- **Autonomous background polling** using Gradio 6's `server_functions`.
|
| 29 |
+
- **Light/dark theme support** completely integrated with Gradio's native `--` CSS variables.
|
| 30 |
+
- **Graceful fallback (Mock Data)** if executed on a machine without `nvidia-smi` (ideal for local development).
|
| 31 |
+
- **Responsive CSS Grid** that automatically adapts the number of columns based on screen size.
|
| 32 |
+
- **Dynamic colored icons** via Lucide (temperature and utilization colors change based on thresholds).
|
| 33 |
+
- **Configurable** refresh rate and timestamp visibility.
|
| 34 |
+
|
| 35 |
+
## Installation
|
| 36 |
+
|
| 37 |
+
```bash
|
| 38 |
+
pip install gradio-gpu-monitor
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
## Usage
|
| 42 |
+
*Note: Make sure to include the Lucide icon library in your `gr.lauch()` head parameter for the icons to render correctly.*
|
| 43 |
+
|
| 44 |
+
```py
|
| 45 |
+
import gradio as gr
|
| 46 |
+
from gradio_gpu_monitor import GPUMonitor
|
| 47 |
+
|
| 48 |
+
# Load Lucide icons via CDN
|
| 49 |
+
head_html = """<script src="https://unpkg.com/lucide@latest"></script>"""
|
| 50 |
+
|
| 51 |
+
with gr.Blocks(head=head_html) as demo:
|
| 52 |
+
gr.Markdown("# 🎛️ System Dashboard")
|
| 53 |
+
|
| 54 |
+
# Simple initialization with default settings (1s refresh)
|
| 55 |
+
GPUMonitor()
|
| 56 |
+
|
| 57 |
+
demo.launch()
|
| 58 |
+
```
|
| 59 |
+
Check out the full example in the [Hugging Face demo.](https://huggingface.co/spaces/elismasilva/gradio_gpu_monitor)
|
| 60 |
+
|
| 61 |
+
| Property | Type | Default | Description |
|
| 62 |
+
| :--- | :--- | :--- | :--- |
|
| 63 |
+
| `update_interval` | `int` | `1000` | Polling interval in milliseconds (how often the GPU data refreshes). |
|
| 64 |
+
| `show_last_updated` | `bool` | `True` | Whether to display the "Last updated: HH:MM:SS" text in the header. |
|
| 65 |
+
| `label` | `str \| None` | `None` | Optional label for the component. |
|
| 66 |
+
| `visible` | `bool` | `True` | Whether the component is visible on the screen. |
|
| 67 |
+
| `elem_id` | `str \| None` | `None` | Custom HTML ID for targeting with CSS or JavaScript. |
|
| 68 |
+
| `elem_classes` | `list[str] \| str \| None` | `None` | Additional CSS classes applied to the component wrapper. |
|
| 69 |
+
|
| 70 |
+
### Example with all properties
|
| 71 |
+
|
| 72 |
+
```py
|
| 73 |
+
gpu_widget = GPUMonitor(
|
| 74 |
+
update_interval=2500, # Refresh every 2.5 seconds
|
| 75 |
+
show_last_updated=False, # Hide the clock text
|
| 76 |
+
label="Hardware Status", # Optional title context
|
| 77 |
+
visible=True,
|
| 78 |
+
elem_id="custom-gpu-monitor",
|
| 79 |
+
elem_classes=["my-custom-class"]
|
| 80 |
+
)
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from gradio_gpu_monitor import GPUMonitor
|
| 3 |
+
|
| 4 |
+
head_html = """<script src="https://unpkg.com/lucide@latest"></script>"""
|
| 5 |
+
|
| 6 |
+
with gr.Blocks() as demo:
|
| 7 |
+
gr.Markdown(
|
| 8 |
+
"""
|
| 9 |
+
# ☰ GPU Monitor Component Demo
|
| 10 |
+
<span>💻 <a href='https://github.com/DEVAIEXP/gradio_component_gpumonitor'>Component GitHub Code</a></span>
|
| 11 |
+
<p>Custom real-time GPU monitoring component for Gradio apps using `gr.HTML`.</p>
|
| 12 |
+
"""
|
| 13 |
+
)
|
| 14 |
+
gr.Markdown("# Control Panel")
|
| 15 |
+
|
| 16 |
+
GPUMonitor(update_interval=2000, show_last_updated=True)
|
| 17 |
+
|
| 18 |
+
if __name__ == "__main__":
|
| 19 |
+
demo.launch(head=head_html, theme=gr.themes.Monochrome())
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
gradio_gpu_monitor
|