ACCA225 commited on
Commit
ee18c52
1 Parent(s): 104ceb5

Update app1.py

Browse files
Files changed (1) hide show
  1. app1.py +30 -11
app1.py CHANGED
@@ -60,15 +60,34 @@ os.system('wandb login 5c00964de1bb95ec1ab24869d4c523c59e0fb8e3')
60
  # 初始化WandB项目
61
  wandb.init(project="gpu-temperature-monitor")
62
 
63
- # 循环获取GPU温度和使用率并记录到WandB
64
- # 获取GPU温度的代码
65
- gpu_temperature_command = "nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader,nounits"
66
- gpu_temperature = int(os.popen(gpu_temperature_command).read().strip())
67
- gpu_usage_command = "nvidia-smi --query-gpu=utilization.gpu --format=csv,noheader,nounits"
68
- gpu_usage = int(os.popen(gpu_usage_command).read().strip())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
- # 将温度和使用率记录到WandB
71
- wandb.log({"GPU 温度": gpu_temperature, "GPU 使用率": gpu_usage})
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()