Update app1.py
Browse files
app1.py
CHANGED
@@ -60,15 +60,34 @@ os.system('wandb login 5c00964de1bb95ec1ab24869d4c523c59e0fb8e3')
|
|
60 |
# 初始化WandB项目
|
61 |
wandb.init(project="gpu-temperature-monitor")
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
os.system(f"python launch.py --api --xformers --enable-insecure-extension-access --ui-settings-file /home/xlab-app-center/config.json --ui-config-file /home/xlab-app-center/ui-config.json --gradio-queue --disable-safe-unpickle --ngrok=2Z4gIgLcc0W20vmdmTHTgwlWXdR_5aHNP91mnkn1mFYXUKKEz")
|
74 |
-
#os.system(f"python launch.py --api --xformers --enable-insecure-extension-access --ui-settings-file /home/xlab-app-center/config.json --ui-config-file /home/xlab-app-center/ui-config.json --gradio-queue --disable-safe-unpickle --ngrok=2Z4gIgLcc0W20vmdmTHTgwlWXdR_5aHNP91mnkn1mFYXUKKEz & python launch.py --api --ui-settings-file /home/xlab-app-center/config.json --ui-config-file /home/xlab-app-center/ui-config.json --xformers --enable-insecure-extension-access --gradio-queue --disable-safe-unpickle --port=7861 --ngrok=2YteSlIvArBGFgXx70rY6MN1ThW_gUnTwjXzT5kbnNozZFL2")
|
|
|
60 |
# 初始化WandB项目
|
61 |
wandb.init(project="gpu-temperature-monitor")
|
62 |
|
63 |
+
import os
|
64 |
+
import threading
|
65 |
+
import wandb
|
66 |
+
|
67 |
+
def wandb():
|
68 |
+
# Assuming you have initialized WandB before this function call
|
69 |
+
# ...
|
70 |
+
|
71 |
+
while True:
|
72 |
+
# Loop to continuously monitor GPU temperature and usage
|
73 |
+
gpu_temperature_command = "nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader,nounits"
|
74 |
+
gpu_temperature = int(os.popen(gpu_temperature_command).read().strip())
|
75 |
+
gpu_usage_command = "nvidia-smi --query-gpu=utilization.gpu --format=csv,noheader,nounits"
|
76 |
+
gpu_usage = int(os.popen(gpu_usage_command).read().strip())
|
77 |
+
|
78 |
+
wandb.log({"GPU 温度": gpu_temperature, "GPU 使用率": gpu_usage})
|
79 |
+
|
80 |
+
def start():
|
81 |
+
os.system(f"python launch.py --api --xformers --enable-insecure-extension-access --ui-settings-file /home/xlab-app-center/config.json --ui-config-file /home/xlab-app-center/ui-config.json --gradio-queue --disable-safe-unpickle --ngrok=2Z4gIgLcc0W20vmdmTHTgwlWXdR_5aHNP91mnkn1mFYXUKKEz")
|
82 |
+
|
83 |
+
# Create threads for each function
|
84 |
+
wandb_thread = threading.Thread(target=wandb)
|
85 |
+
start_thread = threading.Thread(target=start)
|
86 |
+
|
87 |
+
# Start the threads
|
88 |
+
wandb_thread.start()
|
89 |
+
start_thread.start()
|
90 |
|
91 |
+
# Wait for both threads to finish
|
92 |
+
wandb_thread.join()
|
93 |
+
start_thread.join()
|
|
|
|