Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -14,6 +14,7 @@ from playwright.sync_api import sync_playwright
|
|
14 |
from languages import get_language_names
|
15 |
from subtitle import text_output, subtitle_output
|
16 |
|
|
|
17 |
import psutil
|
18 |
import subprocess
|
19 |
from gpustat import GPUStatCollection
|
@@ -68,7 +69,7 @@ def update_gpu_status():
|
|
68 |
memory_used = gpu.memory_used
|
69 |
memory_total = gpu.memory_total
|
70 |
memory_utilization = (memory_used / memory_total) * 100
|
71 |
-
gpu_status=(f"**GPU** {gpu_id}: {gpu_name}\nUtilization: {gpu_utilization}%\n**Memory Used**: {memory_used}MB\n**Memory Total**: {memory_total}MB\n**Memory Utilization**: {memory_utilization:.2f}%\n")
|
72 |
return gpu_status
|
73 |
|
74 |
except Exception as e:
|
@@ -83,18 +84,21 @@ def torch_update_gpu_status():
|
|
83 |
free_memory=gpu_memory[0] /(1024 *1024)
|
84 |
used_memory = (gpu_memory[1] - gpu_memory[0]) / (1024 * 1024)
|
85 |
|
86 |
-
gpu_status = f"**GPU**: {gpu_info}\n**Free Memory**: {free_memory}MB\n**Total Memory**: {total_memory:.2f} MB\n**Used Memory**: {used_memory:.2f} MB\n"
|
87 |
else:
|
88 |
gpu_status = "No GPU available"
|
89 |
return gpu_status
|
90 |
|
91 |
def update_cpu_status():
|
92 |
-
import datetime
|
93 |
current_time = datetime.datetime.utcnow()
|
94 |
time_str = current_time.strftime("%Y-%m-%d %H:%M:%S")
|
95 |
|
96 |
cpu_percent = psutil.cpu_percent()
|
97 |
-
|
|
|
|
|
|
|
|
|
98 |
return cpu_status
|
99 |
|
100 |
def update_status():
|
@@ -446,6 +450,7 @@ with demo:
|
|
446 |
refresh_button = gr.Button("Refresh System Status")
|
447 |
refresh_button.click(refresh_status, None, sys_status_output)
|
448 |
sys_status_output.value = refresh_status()
|
|
|
449 |
|
450 |
if __name__ == "__main__":
|
451 |
demo.queue().launch(ssr_mode=False)
|
|
|
14 |
from languages import get_language_names
|
15 |
from subtitle import text_output, subtitle_output
|
16 |
|
17 |
+
import datetime
|
18 |
import psutil
|
19 |
import subprocess
|
20 |
from gpustat import GPUStatCollection
|
|
|
69 |
memory_used = gpu.memory_used
|
70 |
memory_total = gpu.memory_total
|
71 |
memory_utilization = (memory_used / memory_total) * 100
|
72 |
+
gpu_status=(f"**GPU Name** {gpu_id}: {gpu_name}\nUtilization: {gpu_utilization}%\n**Memory Used**: {memory_used}MB\n**Memory Total**: {memory_total}MB\n**Memory Utilization**: {memory_utilization:.2f}%\n")
|
73 |
return gpu_status
|
74 |
|
75 |
except Exception as e:
|
|
|
84 |
free_memory=gpu_memory[0] /(1024 *1024)
|
85 |
used_memory = (gpu_memory[1] - gpu_memory[0]) / (1024 * 1024)
|
86 |
|
87 |
+
gpu_status = f"**GPU Name**: {gpu_info}\n**Free Memory**: {free_memory}MB\n**Total Memory**: {total_memory:.2f} MB\n**Used Memory**: {used_memory:.2f} MB\n"
|
88 |
else:
|
89 |
gpu_status = "No GPU available"
|
90 |
return gpu_status
|
91 |
|
92 |
def update_cpu_status():
|
|
|
93 |
current_time = datetime.datetime.utcnow()
|
94 |
time_str = current_time.strftime("%Y-%m-%d %H:%M:%S")
|
95 |
|
96 |
cpu_percent = psutil.cpu_percent()
|
97 |
+
|
98 |
+
cpu_info = psutil.cpu_info()
|
99 |
+
cpu_name = cpu_info[0].brand_raw if cpu_info else "Unknown CPU"
|
100 |
+
|
101 |
+
cpu_status = f"**{time_str} (UTC+0)**\n\n**CPU Name**: {cpu_name}\n**CPU Usage**: {cpu_percent}%\n\n"
|
102 |
return cpu_status
|
103 |
|
104 |
def update_status():
|
|
|
450 |
refresh_button = gr.Button("Refresh System Status")
|
451 |
refresh_button.click(refresh_status, None, sys_status_output)
|
452 |
sys_status_output.value = refresh_status()
|
453 |
+
demo.load(update_status, None, sys_status_output, every=3)
|
454 |
|
455 |
if __name__ == "__main__":
|
456 |
demo.queue().launch(ssr_mode=False)
|