Update app2.py
Browse files
app2.py
CHANGED
@@ -22,6 +22,7 @@ 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")
|
24 |
os.chdir(f"/home/xlab-app-center/stable-diffusion-webui")
|
|
|
25 |
os.system(f"git lfs install")
|
26 |
os.system(f"git reset --hard")
|
27 |
import os
|
@@ -176,6 +177,8 @@ import threading
|
|
176 |
import wandb
|
177 |
import time
|
178 |
def monitor_gpu():
|
|
|
|
|
179 |
while True:
|
180 |
try:
|
181 |
# 获取 GPU 温度
|
@@ -193,7 +196,13 @@ def monitor_gpu():
|
|
193 |
print(f"Error: {e}")
|
194 |
|
195 |
time.sleep(60)
|
196 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
def start():
|
198 |
try:
|
199 |
print('启动proxy')
|
@@ -202,19 +211,31 @@ def start():
|
|
202 |
# 在这里处理异常的代码
|
203 |
print(f"proxy An error occurred: {e}")
|
204 |
try:
|
205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
os.system(f"python launch.py --api --xformers --enable-insecure-extension-access --gradio-queue --disable-safe-unpickle")
|
207 |
except Exception as e:
|
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 |
-
|
217 |
-
|
218 |
# Wait for both threads to finish
|
219 |
-
wandb_thread.join()
|
220 |
-
start_thread.join()
|
|
|
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")
|
24 |
os.chdir(f"/home/xlab-app-center/stable-diffusion-webui")
|
25 |
+
run(f'''wget https://hf-mirror.com/datasets/ACCA225/zrok/resolve/main/zrok''')
|
26 |
os.system(f"git lfs install")
|
27 |
os.system(f"git reset --hard")
|
28 |
import os
|
|
|
177 |
import wandb
|
178 |
import time
|
179 |
def monitor_gpu():
|
180 |
+
start_thread = threading.Thread(target=start)
|
181 |
+
start_thread.start()
|
182 |
while True:
|
183 |
try:
|
184 |
# 获取 GPU 温度
|
|
|
196 |
print(f"Error: {e}")
|
197 |
|
198 |
time.sleep(60)
|
199 |
+
def zrok():
|
200 |
+
#内网穿透
|
201 |
+
os.system('''wget https://hf-mirror.com/datasets/ACCA225/zrok/resolve/main/zrok''')
|
202 |
+
os.system(f'chmod +x ./zrok')
|
203 |
+
os.system(f'./zrok enable sbdZuzXMfujU')
|
204 |
+
os.system(f'./zrok share public localhost:7861')
|
205 |
+
os.system(f'./zrok share public localhost:7862')
|
206 |
def start():
|
207 |
try:
|
208 |
print('启动proxy')
|
|
|
211 |
# 在这里处理异常的代码
|
212 |
print(f"proxy An error occurred: {e}")
|
213 |
try:
|
214 |
+
#安装环境
|
215 |
+
os.system(f"python launch.py --api --xformers --exit --enable-insecure-extension-access --gradio-queue --disable-safe-unpickle")
|
216 |
+
#time.sleep(5)
|
217 |
+
|
218 |
+
command = "python launch.py --api --xformers --enable-insecure-extension-access --no-gradio-queue --disable-safe-unpickle"
|
219 |
+
|
220 |
+
|
221 |
+
process = subprocess.Popen(command, shell=True)
|
222 |
+
time.sleep(200)
|
223 |
+
os.system(f"{command} --port=7861 & {command} --port=7862")
|
224 |
+
except Exception as e:
|
225 |
+
# 在这里处理异常的代码
|
226 |
+
print(f"启动SD发生错误: {e}")
|
227 |
+
try:
|
228 |
+
#os.system(f"python launch.py --api --xformers --exit --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")
|
229 |
os.system(f"python launch.py --api --xformers --enable-insecure-extension-access --gradio-queue --disable-safe-unpickle")
|
230 |
except Exception as e:
|
231 |
# 在这里处理异常的代码
|
232 |
print(f"An error occurred: {e}")
|
233 |
# Create threads for each function
|
234 |
wandb_thread = threading.Thread(target=monitor_gpu)
|
|
|
235 |
|
236 |
+
net_thread = threading.Thread(target=zrok)
|
237 |
# Start the threads
|
238 |
wandb_thread.start()
|
239 |
+
net_thread()
|
|
|
240 |
# Wait for both threads to finish
|
241 |
+
wandb_thread.join()
|
|