Update app1.py
Browse files
app1.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import os
|
2 |
# import wandb
|
|
|
3 |
os.chdir(f"/home/xlab-app-center")
|
4 |
os.system(f"git clone https://openi.pcl.ac.cn/2575044704/stable-diffusion-webui-v1.6.1 /home/xlab-app-center/stable-diffusion-webui")
|
5 |
os.system(f"cp /home/xlab-app-center/styles.csv /home/xlab-app-center/stable-diffusion-webui/styles.csv")
|
@@ -9,7 +10,7 @@ os.system(f"git reset --hard")
|
|
9 |
os.chdir(f"/home/xlab-app-center/stable-diffusion-webui/extensions")
|
10 |
|
11 |
plugins = [
|
12 |
-
"https://
|
13 |
"https://gitcode.net/ranting8323/multidiffusion-upscaler-for-automatic1111",
|
14 |
"https://gitcode.net/ranting8323/adetailer",
|
15 |
"https://gitcode.net/ranting8323/sd-webui-prompt-all-in-one",
|
@@ -64,22 +65,35 @@ import os
|
|
64 |
import threading
|
65 |
import wandb
|
66 |
import time
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
|
|
|
|
|
|
|
|
|
71 |
while True:
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
-
wandb.log({"GPU 温度": gpu_temperature, "GPU 使用率": gpu_usage})
|
79 |
time.sleep(60)
|
80 |
|
|
|
81 |
def start():
|
82 |
-
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
|
83 |
|
84 |
# Create threads for each function
|
85 |
wandb_thread = threading.Thread(target=wandb)
|
|
|
1 |
import os
|
2 |
# import wandb
|
3 |
+
os.system("pip install nvidia-ml-py3")
|
4 |
os.chdir(f"/home/xlab-app-center")
|
5 |
os.system(f"git clone https://openi.pcl.ac.cn/2575044704/stable-diffusion-webui-v1.6.1 /home/xlab-app-center/stable-diffusion-webui")
|
6 |
os.system(f"cp /home/xlab-app-center/styles.csv /home/xlab-app-center/stable-diffusion-webui/styles.csv")
|
|
|
10 |
os.chdir(f"/home/xlab-app-center/stable-diffusion-webui/extensions")
|
11 |
|
12 |
plugins = [
|
13 |
+
"https://openi.pcl.ac.cn/2575044704/stable-diffusion-webui-localization-zh_CN2",
|
14 |
"https://gitcode.net/ranting8323/multidiffusion-upscaler-for-automatic1111",
|
15 |
"https://gitcode.net/ranting8323/adetailer",
|
16 |
"https://gitcode.net/ranting8323/sd-webui-prompt-all-in-one",
|
|
|
65 |
import threading
|
66 |
import wandb
|
67 |
import time
|
68 |
+
import time
|
69 |
+
import nvidia_smi
|
70 |
+
import wandb
|
71 |
|
72 |
+
# 初始化 nvidia_smi
|
73 |
+
nvidia_smi.nvmlInit()
|
74 |
+
|
75 |
+
def wandb():
|
76 |
while True:
|
77 |
+
try:
|
78 |
+
# 获取 GPU 温度
|
79 |
+
handle = nvidia_smi.nvmlDeviceGetHandleByIndex(0) # 0 表示第一个 GPU
|
80 |
+
gpu_temperature = nvidia_smi.nvmlDeviceGetTemperature(handle, nvidia_smi.NVML_TEMPERATURE_GPU)
|
81 |
+
|
82 |
+
# 获取 GPU 使用率
|
83 |
+
utilization = nvidia_smi.nvmlDeviceGetUtilizationRates(handle)
|
84 |
+
gpu_usage = utilization.gpu
|
85 |
+
|
86 |
+
# 使用 WandB 记录 GPU 温度和使用率
|
87 |
+
wandb.log({"GPU 温度": gpu_temperature, "GPU 使用率": gpu_usage})
|
88 |
+
|
89 |
+
except Exception as e:
|
90 |
+
print(f"Error: {e}")
|
91 |
|
|
|
92 |
time.sleep(60)
|
93 |
|
94 |
+
|
95 |
def start():
|
96 |
+
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")
|
97 |
|
98 |
# Create threads for each function
|
99 |
wandb_thread = threading.Thread(target=wandb)
|