Spaces:
Runtime error
Runtime error
Download app.py from mapleadmin/GPT: direct link, hf CLI and curl.
- Browser
- Download file 860 Bytes
-
https://huggingface.co/spaces/mapleadmin/GPT/resolve/refs%2Fpr%2F3/app.py
- Command line
-
hf download hf://spaces/mapleadmin/GPT@refs/pr/3/app.py
-
curl -L -o app.py https://huggingface.co/spaces/mapleadmin/GPT/resolve/refs%2Fpr%2F3/app.py
860 Bytes
| import streamlit as st | |
| import GPUtil | |
| import time | |
| import threading | |
| # Function to get GPU utilization | |
| def get_gpu_utilization(): | |
| while True: | |
| gpus = GPUtil.getGPUs() | |
| if gpus: | |
| gpu = gpus[0] # Assuming a single GPU | |
| utilization = gpu.load * 100 | |
| st.write(f"GPU Utilization: {utilization:.2f}%") | |
| else: | |
| st.write("No GPU found.") | |
| time.sleep(1) | |
| # Streamlit app | |
| def main(): | |
| st.title("GPU Utilization Monitor") | |
| # Start a thread to continuously monitor GPU utilization | |
| gpu_thread = threading.Thread(target=get_gpu_utilization) | |
| gpu_thread.daemon = True | |
| gpu_thread.start() | |
| # Run the app for at least 3 minutes | |
| end_time = time.time() + 180 # 180 seconds = 3 minutes | |
| while time.time() < end_time: | |
| pass | |
| if __name__ == "__main__": | |
| main() | |