Spaces:
Runtime error

GPT / app.py
mapleadmin's picture
Update app.py
917e27b
Raw History Blame
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()