ACCA225 commited on
Commit
8554be2
1 Parent(s): 2f5e2a4

Update app3.py

Browse files
Files changed (1) hide show
  1. app3.py +2 -28
app3.py CHANGED
@@ -17,7 +17,7 @@ import time
17
  import socket
18
  from concurrent.futures import ProcessPoolExecutor
19
  # import wandb
20
- os.system("pip install nvidia-ml-py3")
21
  os.chdir(f"/home/xlab-app-center")
22
  os.system(f"git clone https://openi.pcl.ac.cn/2575044704/sd-v1.7.0 /home/xlab-app-center/stable-diffusion-webui")
23
  os.system(f"cp /home/xlab-app-center/styles.csv /home/xlab-app-center/stable-diffusion-webui/styles.csv")
@@ -165,34 +165,12 @@ def localProxy():
165
  run(f'''nginx -c /home/xlab-app-center/stable-diffusion-webui/proxy_nginx.conf''')
166
  run(f'''nginx -s reload''')
167
 
168
- # WandB登录
169
- os.system('wandb login 5c00964de1bb95ec1ab24869d4c523c59e0fb8e3')
170
-
171
- # 初始化WandB项目
172
- wandb.init(project="gpu-temperature-monitor")
173
 
174
  import os
175
  import threading
176
  import wandb
177
  import time
178
- def monitor_gpu():
179
- while True:
180
- try:
181
- # 获取 GPU 温度
182
- handle = nvidia_smi.nvmlDeviceGetHandleByIndex(0) # 0 表示第一个 GPU
183
- gpu_temperature = nvidia_smi.nvmlDeviceGetTemperature(handle, nvidia_smi.NVML_TEMPERATURE_GPU)
184
-
185
- # 获取 GPU 使用率
186
- utilization = nvidia_smi.nvmlDeviceGetUtilizationRates(handle)
187
- gpu_usage = utilization.gpu
188
-
189
- # 使用 WandB 记录 GPU 温度和使用率
190
- wandb.log({"GPU 温度": gpu_temperature, "GPU 使用率": gpu_usage})
191
 
192
- except Exception as e:
193
- print(f"Error: {e}")
194
-
195
- time.sleep(60)
196
 
197
  def start():
198
  try:
@@ -208,13 +186,9 @@ def start():
208
  # 在这里处理异常的代码
209
  print(f"An error occurred: {e}")
210
  # Create threads for each function
211
- wandb_thread = threading.Thread(target=monitor_gpu)
212
  start_thread = threading.Thread(target=start)
213
 
214
- # Start the threads
215
- wandb_thread.start()
216
  start_thread.start()
217
 
218
- # Wait for both threads to finish
219
- wandb_thread.join()
220
  start_thread.join()
 
17
  import socket
18
  from concurrent.futures import ProcessPoolExecutor
19
  # import wandb
20
+ #os.system("pip install nvidia-ml-py3")
21
  os.chdir(f"/home/xlab-app-center")
22
  os.system(f"git clone https://openi.pcl.ac.cn/2575044704/sd-v1.7.0 /home/xlab-app-center/stable-diffusion-webui")
23
  os.system(f"cp /home/xlab-app-center/styles.csv /home/xlab-app-center/stable-diffusion-webui/styles.csv")
 
165
  run(f'''nginx -c /home/xlab-app-center/stable-diffusion-webui/proxy_nginx.conf''')
166
  run(f'''nginx -s reload''')
167
 
 
 
 
 
 
168
 
169
  import os
170
  import threading
171
  import wandb
172
  import time
 
 
 
 
 
 
 
 
 
 
 
 
 
173
 
 
 
 
 
174
 
175
  def start():
176
  try:
 
186
  # 在这里处理异常的代码
187
  print(f"An error occurred: {e}")
188
  # Create threads for each function
189
+
190
  start_thread = threading.Thread(target=start)
191
 
 
 
192
  start_thread.start()
193
 
 
 
194
  start_thread.join()