ACCA225 commited on
Commit
acdcf81
1 Parent(s): e506eb0

Update app2.py

Browse files
Files changed (1) hide show
  1. app2.py +351 -349
app2.py CHANGED
@@ -20,367 +20,369 @@ from concurrent.futures import ProcessPoolExecutor
20
  import base64
21
  import subprocess
22
 
23
-
24
- def notbook():
25
- os.system("pip install jupyterlab")
26
- os.system("pip install pyngrok")
27
- # 构建命令字符串
28
- ngrok_command = f"ngrok http 8889 --authtoken=2cdw5pJsqgsq1igQKeHIpNwTNG7_7LQD3jojKKQ7PzcnNkok5"
29
- ngrok_command2 = f"ngrok tunnel --label edge=edghts_2doueG9BDi9rCXUGnsSsNbTab8H --authtoken=2douOsr61tUyYwMVF3lfj9uZGoa_6FPJ2x1xhKPbL6z4euKkM --region=ap http://localhost:8889"
30
- jupyter_command = "jupyter-lab --no-browser --ip=0.0.0.0 --allow-root --notebook-dir=/ --port=8889 --LabApp.allow_origin=* --LabApp.token= --LabApp.base_url="
31
-
32
- # 启动 ngrok 进程
33
- ngrok_process = subprocess.Popen(ngrok_command, shell=True)
34
- time.sleep(30)
35
- ngrok_process2 = subprocess.Popen(ngrok_command2, shell=True)
36
- # 启动 Jupyter 进程
37
- jupyter_process = subprocess.Popen(jupyter_command, shell=True)
38
- #os.system(f"ngrok tunnel --authtoken={ngrok_token} --region=ap http://localhost:8888 & python jupyter-lab --ServerApp.shutdown_no_activity_timeout=1800 --TerminalManager.cull_inactive_timeout=1800 --TerminalManager.cull_interval=300 --MappingKernelManager.cull_idle_timeout=1800 --MappingKernelManager.cull_interval=300 --MappingKernelManager.cull_connected=True --MappingKernelManager.cull_busy=True --no-browser --ip=0.0.0.0 --allow-root --notebook-dir=/ --port=8888 --LabApp.token= --LabApp.allow_origin=* --LabApp.base_url=")
39
-
40
- ngrok_token = "2bgXLjjKFvxfbuZFlR2NMZkvL8n_4WrK7f15FLtWb8p7v3oaF"
41
- _ngrok_token = "2CXyNlT9xGfFoL5ruI6hQV20FNq_7tbmuzS9RtyNTkyEe1J6C"
42
-
43
- os.system("pip install nvidia-ml-py3")
44
- os.chdir(f"/home/xlab-app-center")
45
- os.system(f"git clone https://openi.pcl.ac.cn/2575044704/stable-diffusion-webui-v1.8.0 /home/xlab-app-center/stable-diffusion-webui")
46
-
47
- os.system(f"cp /home/xlab-app-center/styles.csv /home/xlab-app-center/stable-diffusion-webui/styles.csv")
48
- os.chdir(f"/home/xlab-app-center/stable-diffusion-webui")
49
- os.system(f"git lfs install")
50
- os.system(f"git reset --hard")
51
- import os
52
-
53
- ngrok_token = "2bgXLjjKFvxfbuZFlR2NMZkvL8n_4WrK7f15FLtWb8p7v3oaF" #7862端口
54
- _ngrok_token = "2CXyNlT9xGfFoL5ruI6hQV20FNq_7tbmuzS9RtyNTkyEe1J6C" #7863端口
55
-
56
- def remove_restart():
57
- os.chdir("/home/xlab-app-center/stable-diffusion-webui/html")
58
- os.system("rm ./footer.html && wget -O footer.html https://hf-mirror.com/datasets/ACCA225/openxlab/resolve/main/footer.html")
59
- os.chdir("/home/xlab-app-center/stable-diffusion-webui/modules")
60
- os.system("rm ./ui_settings.py && wget -O ui_settings.py https://hf-mirror.com/datasets/ACCA225/openxlab/resolve/main/ui_settings.py")
61
- remove_restart()
62
- def create_directory(directory_path):
63
- if not os.path.exists(directory_path):
64
- os.makedirs(directory_path)
65
-
66
- def download_file(url, destination_path):
67
- os.system(f'wget -O {destination_path} {url}')
68
-
69
- # 设置基本路径
70
- base_directory = '/home/xlab-app-center/stable-diffusion-webui'
71
- configs_directory = os.path.join(base_directory, 'configs')
72
-
73
- # 创建configs文件夹
74
- create_directory(configs_directory)
75
-
76
- # 下载配置文件
77
- #download_file('https://hf-mirror.com/datasets/ACCA225/openxlab/resolve/main/config-pub.json', os.path.join(configs_directory, 'config.json'))
78
- #download_file('https://hf-mirror.com/datasets/ACCA225/openxlab/resolve/main/ui-config-pri2.json', os.path.join(configs_directory, 'ui-config-pri.json'))
79
- #download_file('https://hf-mirror.com/datasets/ACCA225/openxlab/resolve/main/ui-config-pub.json', os.path.join(configs_directory, 'ui-config.json'))
80
- # 下载配置文件
81
- download_file('https://hf-mirror.com/datasets/ACCA225/openxlab/resolve/main/config-pub.json', os.path.join(base_directory, 'config.json'))
82
- download_file('https://hf-mirror.com/datasets/ACCA225/openxlab/resolve/main/ui-config-pri2.json', os.path.join(base_directory, 'ui-config-pri.json'))
83
- download_file('https://hf-mirror.com/datasets/ACCA225/openxlab/resolve/main/ui-config-pub.json', os.path.join(base_directory, 'ui-config.json'))
84
- download_file('https://hf-mirror.com/datasets/ACCA225/openxlab/resolve/main/ui-config-pub2.json', os.path.join(base_directory, 'ui-config2.json'))
85
-
86
- os.chdir(f"/home/xlab-app-center/stable-diffusion-webui/extensions")
87
- os.system(f"rm -rf ./batchlinks-webui")
88
- os.system(f"rm -rf ./sd-extension-system-info")
89
- show_shell_info = False
90
- def run(command, cwd=None, desc=None, errdesc=None, custom_env=None,try_error:bool=True) -> str:
91
- global show_shell_info
92
- if desc is not None:
93
- print(desc)
94
-
95
- run_kwargs = {
96
- "args": command,
97
- "shell": True,
98
- "cwd": cwd,
99
- "env": os.environ if custom_env is None else custom_env,
100
- "encoding": 'utf8',
101
- "errors": 'ignore',
102
- }
103
-
104
- if not show_shell_info:
105
- run_kwargs["stdout"] = run_kwargs["stderr"] = subprocess.PIPE
106
-
107
- result = subprocess.run(**run_kwargs)
108
-
109
- if result.returncode != 0:
110
- error_bits = [
111
- f"{errdesc or 'Error running command'}.",
112
- f"Command: {command}",
113
- f"Error code: {result.returncode}",
114
- ]
115
- if result.stdout:
116
- error_bits.append(f"stdout: {result.stdout}")
117
- if result.stderr:
118
- error_bits.append(f"stderr: {result.stderr}")
119
- if try_error:
120
- print((RuntimeError("\n".join(error_bits))))
121
- else:
122
- raise RuntimeError("\n".join(error_bits))
123
-
124
- if show_shell_info:
125
- print((result.stdout or ""))
126
- return (result.stdout or "")
127
- import subprocess
128
- def sdmodel():
129
- def download_with_aria2(urls):
130
- # 使用循环遍历所有的下载链接
131
- for url in urls:
132
- # 将huggingface.co替换为hf-mirror.com
133
- url = url.replace('huggingface.co', 'hf-mirror.com')
134
- file_name = url.split('/')[-1].split('?')[0]
135
- # 构建aria2c命令
136
- command = f'aria2c -x 16 -s 16 -c -k 1M -o "{file_name}" "{url}" -d /home/xlab-app-center/stable-diffusion-webui/models/Stable-diffusion'
137
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  try:
139
- # 使用subprocess模块运行aria2c命令
140
- subprocess.run(command, shell=True, check=True)
141
- except subprocess.CalledProcessError as e:
142
- # 打印错误信息(如果有)
143
- print(f'Error downloading {url}: {e}')
144
-
145
- # 直接将链接作为多行字符串传递给函数
146
- download_urls = """
147
- https://huggingface.co/HiroHiroHirook/meinamix_meinaV8/resolve/main/meinamix_meinaV8.safetensors?download=true
148
- https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/anything_v50.safetensors?download=true
149
- https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/blindbox_v1_mix.safetensors?download=true
150
- https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/cuteyukimixAdorable_naiV3style.safetensors?download=true
151
- https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/ddicon_v10.ckpt?download=true
152
- https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/meinamix_meinaV11.safetensors?download=true
153
- https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/meinapastel_v6-inpainting.safetensors?download=true
154
- https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/meinapastel_v6Pastel.safetensors?download=true
155
- https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/midjourney_20230624181825.safetensors?download=true
156
- https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/mixProV4_v4.safetensors?download=true
157
- https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/qteamixQ_omegaFp16.safetensors?download=true
158
- https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/uberRealisticPornMerge_urpmv13.safetensors?download=true
159
- https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/velaMix_velaMixVersion2.safetensors?download=true
160
- """
161
-
162
- # 使用字符串的splitlines方法将字符串分割成列表
163
- urls_list = download_urls.strip().splitlines()
164
-
165
- # 调用函数开始下载
166
- download_with_aria2(urls_list)
167
- #sdmodel()
168
- def mkdirs(path, exist_ok=True):
169
- if path and not Path(path).exists():
170
- os.makedirs(path,exist_ok=exist_ok)
171
- plugins = [
172
- "https://gitcode.net/overbill1683/stable-diffusion-webui-localization-zh_Hans",
173
- #"https://gitcode.net/ranting8323/multidiffusion-upscaler-for-automatic1111",
174
- "https://gitcode.net/ranting8323/adetailer",
175
- "https://gitcode.net/ranting8323/sd-webui-inpaint-anything",
176
- "https://gitcode.net/ranting8323/a1111-sd-webui-tagcomplete",
177
- "https://gitcode.net/nightaway/sd-webui-infinite-image-browsing",
178
- "https://openi.pcl.ac.cn/2575044704/sd-extension-system-info",
179
- "https://openi.pcl.ac.cn/2575044704/batchlinks-webui",
180
- 'https://openi.pcl.ac.cn/2575044704/stable-diffusion-webui-localization-zh_CN',
181
- 'https://openi.pcl.ac.cn/2575044704/sd-webui-lora-block-weight',
182
- 'https://openi.pcl.ac.cn/2575044704/sd-skin-extension',
183
- "https://kkgithub.com/thygate/stable-diffusion-webui-depthmap-script.git",
184
- #"https://gitcode.net/ranting8323/sd-webui-controlnet",
185
- #"https://kkgithub.com/SignalFlagZ/sd-webui-civbrowser.git",
186
- #"https://kkgithub.com/continue-revolution/sd-webui-animatediff.git",
187
- #"https://kkkkgithub.com/aigc-apps/sd-webui-EasyPhoto.git",
188
- "https://kkgithub.com/Iyashinouta/sd-model-downloader.git",
189
- "https://kkgithub.com/fkunn1326/openpose-editor.git",
190
- "https://kkgithub.com/zero01101/openOutpaint-webUI-extension.git",
191
- "https://kkgithub.com/LonicaMewinsky/gif2gif.git",
192
- #"https://kkgithub.com/modelscope/facechain.git",
193
- "https://openi.pcl.ac.cn/2575044704/sd-webui-controlnet",
194
- "https://openi.pcl.ac.cn/2575044704/sd-webui-agent-scheduler",
195
- "https://openi.pcl.ac.cn/2575044704/sd-webui-depth-lib"
196
- ]
197
- suffix_1 = "Nyan9"
198
- suffix_2 = "BiliBili"
199
- needed_extensions = [
200
- "https://openi.pcl.ac.cn/2575044704/sd-extension-system-info",
201
- "https://openi.pcl.ac.cn/2575044704/batchlinks-webui",
202
- ]
203
- os.system("rm -rf /home/xlab-app-center/stable-diffusion-webui/extensions/sd-webui-animatediff/")
204
- for plugin in plugins:
205
- os.system(f"git clone {plugin}")
206
- #for plugin in needed_extensions:
207
- # os.system(f"git clone {plugin}")
208
- os.makedirs('/home/xlab-app-center/stable-diffusion-webui/models/adetailer', exist_ok=True)
209
- os.chdir(f"/home/xlab-app-center/stable-diffusion-webui/models/adetailer")
210
- os.system(f"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://hf-mirror.com/Bingsu/adetailer/resolve/main/hand_yolov8s.pt -d /home/xlab-app-center/stable-diffusion-webui/models/adetailer -o hand_yolov8s.pt")
211
- os.system(f"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://hf-mirror.com/Bingsu/adetailer/resolve/main/hand_yolov8n.pt -d /home/xlab-app-center/stable-diffusion-webui/models/adetailer -o hand_yolov8n.pt")
212
- os.system(f"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://hf-mirror.com/datasets/ACCC1380/private-model/resolve/main/kaggle/input/museum/131-half.safetensors -d /home/xlab-app-center/stable-diffusion-webui/models/Stable-diffusion -o [萌二次元]131-half.safetensors")
213
- os.system(f"rm /home/xlab-app-center/stable-diffusion-webui/models/Stable-diffusion/*porn*.safetensors")
214
-
215
- os.system(f"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://hf-mirror.com/datasets/ACCC1380/private-model/resolve/main/ba.safetensors -d /home/xlab-app-center/stable-diffusion-webui/models/Lora -o ba.safetensors")
216
- os.system(f"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://hf-mirror.com/datasets/ACCC1380/private-model/resolve/main/racaco2.safetensors -d /home/xlab-app-center/stable-diffusion-webui/models/Lora -o racaco2.safetensors")
217
- os.system(f"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://hf-mirror.com/coinz/Add-detail/resolve/main/add_detail.safetensors -d /home/xlab-app-center/stable-diffusion-webui/models/Lora -o add_detail.safetensors")
218
- os.system(f"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://hf-mirror.com/datasets/VASVASVAS/vae/resolve/main/pastel-waifu-diffusion.vae.pt -d /home/xlab-app-center/stable-diffusion-webui/models/VAE -o pastel-waifu-diffusion.vae.pt")
219
- # os.system(f"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://download.openxlab.org.cn/models/camenduru/sdxl-refiner-1.0/weight//sd_xl_refiner_1.0.safetensors -d /home/xlab-app-center/stable-diffusion-webui/models/Stable-diffusion -o sd_xl_refiner_1.0.safetensors")
220
- # os.system(f"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://download.openxlab.org.cn/models/camenduru/cyber-realistic/weight//cyberrealistic_v32.safetensors -d /home/xlab-app-center/stable-diffusion-webui/models/Stable-diffusion -o cyberrealistic_v32.safetensors")
221
- os.chdir(f"/home/xlab-app-center/stable-diffusion-webui")
222
- print('webui launching...')
223
- pwd_1 = ngrok_token + suffix_1
224
- pwd_2 = _ngrok_token + suffix_2
225
- package_envs = [
226
- {"env": "STABLE_DIFFUSION_REPO", "url": os.environ.get('STABLE_DIFFUSION_REPO', "https://gitcode.net/overbill1683/stablediffusion")},
227
- {"env": "STABLE_DIFFUSION_XL_REPO", "url": os.environ.get('STABLE_DIFFUSION_XL_REPO', "https://gitcode.net/overbill1683/generative-models")},
228
- {"env": "K_DIFFUSION_REPO", "url": os.environ.get('K_DIFFUSION_REPO', "https://gitcode.net/overbill1683/k-diffusion")},
229
- {"env": "CODEFORMER_REPO", "url": os.environ.get('CODEFORMER_REPO', "https://gitcode.net/overbill1683/CodeFormer")},
230
- {"env": "BLIP_REPO", "url": os.environ.get('BLIP_REPO', "https://gitcode.net/overbill1683/BLIP")},
231
- ]
232
- os.environ["PIP_INDEX_URL"] = "https://mirrors.aliyun.com/pypi/simple/"
233
- for i in package_envs:
234
- os.environ[i["env"]] = i["url"]
235
 
236
- import os
237
- import time
238
- import wandb
239
- import nvidia_smi
240
- import os
241
- import time
242
- import wandb
243
-
244
- # nginx 反向代理配置文件
245
- def echoToFile(content:str,path:str):
246
- if path.find('/') >= 0:
247
- _path = '/'.join(path.split('/')[:-1])
248
- run(f'''mkdir -p {_path}''')
249
- with open(path,'w') as sh:
250
- sh.write(content)
251
- # 检查网络
252
- def check_service(host, port):
253
- try:
254
- socket.create_connection((host, port), timeout=5)
255
- return True
256
- except socket.error:
257
- return False
258
- def localProxy():
259
- os.system('sudo apt install nginx -y')
260
- download_file('https://huggingface.co/datasets/ACCA225/openxlab/resolve/main/proxy_nginx.conf', os.path.join(base_directory, 'proxy_nginx.conf'))
261
- if not check_service('localhost',_server_port):
262
- run(f'''nginx -c /home/xlab-app-center/stable-diffusion-webui/proxy_nginx.conf''')
263
- run(f'''nginx -s reload''')
264
-
265
- # WandB登录
266
- os.system('wandb login 5c00964de1bb95ec1ab24869d4c523c59e0fb8e3')
267
- nvidia_smi.nvmlInit()
268
- # 初始化WandB项目
269
- wandb.init(project="gpu-temperature-monitor")
270
-
271
- import threading
272
- import requests
273
 
274
- def check_website(url):
275
- try:
276
- response = requests.get(url)
277
- if response.status_code == 200:
278
- print(f"The website {url} is accessible.")
279
- else:
280
- print(f"The website {url} returned status code: {response.status_code}")
281
- notbook()
282
- except requests.exceptions.RequestException as e:
283
- print(f"An error occurred while trying to access {url}: {e}")
284
 
285
- def run_check_periodically(url, interval):
286
- check_website(url)
287
- threading.Timer(interval, run_check_periodically, args=(url, interval)).start()
288
 
 
 
 
289
 
290
- import os
291
- import threading
292
- import wandb
293
- import time
294
- def monitor_gpu():
295
- while True:
296
- try:
297
- # 获取 GPU 温度
298
- handle = nvidia_smi.nvmlDeviceGetHandleByIndex(0) # 0 表示第一个 GPU
299
- gpu_temperature = nvidia_smi.nvmlDeviceGetTemperature(handle, nvidia_smi.NVML_TEMPERATURE_GPU)
300
 
301
- # 获取 GPU 使用率
302
- utilization = nvidia_smi.nvmlDeviceGetUtilizationRates(handle)
303
- gpu_usage = utilization.gpu
304
 
305
- # 使用 WandB 记录 GPU 温度和使用率
306
- wandb.log({"GPU 温度": gpu_temperature, "GPU 使用率": gpu_usage})
307
 
 
 
 
308
  except Exception as e:
309
- print(f"Error: {e}")
310
-
311
- time.sleep(60)
312
- def zrok():
313
- notbook()
314
-
315
- #os.system("wget https://hf-mirror.com/datasets/ACCA225/frp-1/resolve/main/frpc")
316
- #os.system("chmod +x ./frpc")
317
- #os.system("./frpc -f bsnehoeds17ett71i2cr79ujoa7ndkxz:13738352 & ./frpc -f bsnehoeds17ett71i2cr79ujoa7ndkxz:13738353")
318
- pass
319
-
320
- _pwd_1 = base64.b64encode(pwd_1.encode()).decode()
321
- _pwd_2 = base64.b64encode(pwd_2.encode()).decode()
322
-
323
- apitoken = "{}:{}".format(_pwd_1, _pwd_2)
324
- def start():
325
-
326
- try:
327
- #安装环境
328
- os.system(f"python launch.py --api --xformers --exit --enable-insecure-extension-access --gradio-queue --disable-safe-unpickle")
329
- except Exception as e:
330
- # 在这里处理异常的代码
331
- print(f"启动SD发生错误: {e}")
332
- try:
333
- while True:
334
- #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")
335
- os.system(f"python launch.py --xformers --enable-insecure-extension-access --gradio-queue --disable-safe-unpickle --allow-code")
336
- except Exception as e:
337
- # 在这里处理异常的代码
338
- print(f"启动SD发生错误: {e}")
339
 
340
- # 实例保活
341
- import time
342
 
343
- def session_saver():
344
- try:
345
- import cupy as cp
346
- except ImportError:
347
- print("cupy模块未安装,正在安装...")
348
  try:
349
- import pip
350
- pip.main(['install', 'cupy'])
351
  import cupy as cp
352
  except ImportError:
353
- print("无法安装模块,请确保已正确安装pip。")
354
- return
355
-
356
- while True:
357
- for _ in range(11):
358
- matrix_a = cp.random.rand(10000, 10000)
359
- matrix_b = cp.random.rand(10000, 10000)
360
- result = cp.dot(matrix_a, matrix_b)
361
- print("实例保活:", result)
362
- del matrix_a, matrix_b, result
363
- cp.cuda.Stream.null.synchronize()
364
- time.sleep(500)
365
-
366
- #keepliving_thread = threading.Thread(target=session_saver)
367
- net_thread = threading.Thread(target=zrok)
368
-
369
- net_thread.start()
370
- #keepliving_thread.start()
371
-
372
- start_thread = threading.Thread(target=start)
373
- start_thread.start()
374
- # 要检测的网站
375
- website_url = "https://surely-definite-monarch.ngrok-free.app"
376
-
377
- # 间隔时间(秒)
378
- interval = 1800
379
-
380
- # 第一次立即运行一次
381
- #run_check_periodically(website_url, interval)
382
-
383
- monitor_gpu()
384
-
385
- #keepliving_thread.join()
386
- time.sleep(9999999)
 
 
 
 
 
 
 
 
 
20
  import base64
21
  import subprocess
22
 
23
+ try:
24
+ def notbook():
25
+ os.system("pip install jupyterlab")
26
+ os.system("pip install pyngrok")
27
+ # 构建命令字符串
28
+ ngrok_command = f"ngrok http 8889 --authtoken=2cdw5pJsqgsq1igQKeHIpNwTNG7_7LQD3jojKKQ7PzcnNkok5"
29
+ ngrok_command2 = f"ngrok tunnel --label edge=edghts_2doueG9BDi9rCXUGnsSsNbTab8H --authtoken=2douOsr61tUyYwMVF3lfj9uZGoa_6FPJ2x1xhKPbL6z4euKkM --region=ap http://localhost:8889"
30
+ jupyter_command = "jupyter-lab --no-browser --ip=0.0.0.0 --allow-root --notebook-dir=/ --port=8889 --LabApp.allow_origin=* --LabApp.token= --LabApp.base_url="
31
+
32
+ # 启动 ngrok 进程
33
+ ngrok_process = subprocess.Popen(ngrok_command, shell=True)
34
+ time.sleep(30)
35
+ ngrok_process2 = subprocess.Popen(ngrok_command2, shell=True)
36
+ # 启动 Jupyter 进程
37
+ jupyter_process = subprocess.Popen(jupyter_command, shell=True)
38
+ #os.system(f"ngrok tunnel --authtoken={ngrok_token} --region=ap http://localhost:8888 & python jupyter-lab --ServerApp.shutdown_no_activity_timeout=1800 --TerminalManager.cull_inactive_timeout=1800 --TerminalManager.cull_interval=300 --MappingKernelManager.cull_idle_timeout=1800 --MappingKernelManager.cull_interval=300 --MappingKernelManager.cull_connected=True --MappingKernelManager.cull_busy=True --no-browser --ip=0.0.0.0 --allow-root --notebook-dir=/ --port=8888 --LabApp.token= --LabApp.allow_origin=* --LabApp.base_url=")
39
+
40
+ ngrok_token = "2bgXLjjKFvxfbuZFlR2NMZkvL8n_4WrK7f15FLtWb8p7v3oaF"
41
+ _ngrok_token = "2CXyNlT9xGfFoL5ruI6hQV20FNq_7tbmuzS9RtyNTkyEe1J6C"
42
+
43
+ os.system("pip install nvidia-ml-py3")
44
+ os.chdir(f"/home/xlab-app-center")
45
+ os.system(f"git clone https://openi.pcl.ac.cn/2575044704/stable-diffusion-webui-v1.8.0 /home/xlab-app-center/stable-diffusion-webui")
46
+
47
+ os.system(f"cp /home/xlab-app-center/styles.csv /home/xlab-app-center/stable-diffusion-webui/styles.csv")
48
+ os.chdir(f"/home/xlab-app-center/stable-diffusion-webui")
49
+ os.system(f"git lfs install")
50
+ os.system(f"git reset --hard")
51
+ import os
52
+
53
+ ngrok_token = "2bgXLjjKFvxfbuZFlR2NMZkvL8n_4WrK7f15FLtWb8p7v3oaF" #7862端口
54
+ _ngrok_token = "2CXyNlT9xGfFoL5ruI6hQV20FNq_7tbmuzS9RtyNTkyEe1J6C" #7863端口
55
+
56
+ def remove_restart():
57
+ os.chdir("/home/xlab-app-center/stable-diffusion-webui/html")
58
+ os.system("rm ./footer.html && wget -O footer.html https://hf-mirror.com/datasets/ACCA225/openxlab/resolve/main/footer.html")
59
+ os.chdir("/home/xlab-app-center/stable-diffusion-webui/modules")
60
+ os.system("rm ./ui_settings.py && wget -O ui_settings.py https://hf-mirror.com/datasets/ACCA225/openxlab/resolve/main/ui_settings.py")
61
+ remove_restart()
62
+ def create_directory(directory_path):
63
+ if not os.path.exists(directory_path):
64
+ os.makedirs(directory_path)
65
+
66
+ def download_file(url, destination_path):
67
+ os.system(f'wget -O {destination_path} {url}')
68
+
69
+ # 设置基本路径
70
+ base_directory = '/home/xlab-app-center/stable-diffusion-webui'
71
+ configs_directory = os.path.join(base_directory, 'configs')
72
+
73
+ # 创建configs文件夹
74
+ create_directory(configs_directory)
75
+
76
+ # 下载配置文件
77
+ #download_file('https://hf-mirror.com/datasets/ACCA225/openxlab/resolve/main/config-pub.json', os.path.join(configs_directory, 'config.json'))
78
+ #download_file('https://hf-mirror.com/datasets/ACCA225/openxlab/resolve/main/ui-config-pri2.json', os.path.join(configs_directory, 'ui-config-pri.json'))
79
+ #download_file('https://hf-mirror.com/datasets/ACCA225/openxlab/resolve/main/ui-config-pub.json', os.path.join(configs_directory, 'ui-config.json'))
80
+ # 下载配置文件
81
+ download_file('https://hf-mirror.com/datasets/ACCA225/openxlab/resolve/main/config-pub.json', os.path.join(base_directory, 'config.json'))
82
+ download_file('https://hf-mirror.com/datasets/ACCA225/openxlab/resolve/main/ui-config-pri2.json', os.path.join(base_directory, 'ui-config-pri.json'))
83
+ download_file('https://hf-mirror.com/datasets/ACCA225/openxlab/resolve/main/ui-config-pub.json', os.path.join(base_directory, 'ui-config.json'))
84
+ download_file('https://hf-mirror.com/datasets/ACCA225/openxlab/resolve/main/ui-config-pub2.json', os.path.join(base_directory, 'ui-config2.json'))
85
+
86
+ os.chdir(f"/home/xlab-app-center/stable-diffusion-webui/extensions")
87
+ os.system(f"rm -rf ./batchlinks-webui")
88
+ os.system(f"rm -rf ./sd-extension-system-info")
89
+ show_shell_info = False
90
+ def run(command, cwd=None, desc=None, errdesc=None, custom_env=None,try_error:bool=True) -> str:
91
+ global show_shell_info
92
+ if desc is not None:
93
+ print(desc)
94
+
95
+ run_kwargs = {
96
+ "args": command,
97
+ "shell": True,
98
+ "cwd": cwd,
99
+ "env": os.environ if custom_env is None else custom_env,
100
+ "encoding": 'utf8',
101
+ "errors": 'ignore',
102
+ }
103
+
104
+ if not show_shell_info:
105
+ run_kwargs["stdout"] = run_kwargs["stderr"] = subprocess.PIPE
106
+
107
+ result = subprocess.run(**run_kwargs)
108
+
109
+ if result.returncode != 0:
110
+ error_bits = [
111
+ f"{errdesc or 'Error running command'}.",
112
+ f"Command: {command}",
113
+ f"Error code: {result.returncode}",
114
+ ]
115
+ if result.stdout:
116
+ error_bits.append(f"stdout: {result.stdout}")
117
+ if result.stderr:
118
+ error_bits.append(f"stderr: {result.stderr}")
119
+ if try_error:
120
+ print((RuntimeError("\n".join(error_bits))))
121
+ else:
122
+ raise RuntimeError("\n".join(error_bits))
123
+
124
+ if show_shell_info:
125
+ print((result.stdout or ""))
126
+ return (result.stdout or "")
127
+ import subprocess
128
+ def sdmodel():
129
+ def download_with_aria2(urls):
130
+ # 使用循环遍历所有的下载链接
131
+ for url in urls:
132
+ # 将huggingface.co替换为hf-mirror.com
133
+ url = url.replace('huggingface.co', 'hf-mirror.com')
134
+ file_name = url.split('/')[-1].split('?')[0]
135
+ # 构建aria2c命令
136
+ command = f'aria2c -x 16 -s 16 -c -k 1M -o "{file_name}" "{url}" -d /home/xlab-app-center/stable-diffusion-webui/models/Stable-diffusion'
137
+
138
+ try:
139
+ # 使用subprocess模块运行aria2c命令
140
+ subprocess.run(command, shell=True, check=True)
141
+ except subprocess.CalledProcessError as e:
142
+ # 打印错误信息(如果有)
143
+ print(f'Error downloading {url}: {e}')
144
+
145
+ # 直接将链接作为多行字符串传递给函数
146
+ download_urls = """
147
+ https://huggingface.co/HiroHiroHirook/meinamix_meinaV8/resolve/main/meinamix_meinaV8.safetensors?download=true
148
+ https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/anything_v50.safetensors?download=true
149
+ https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/blindbox_v1_mix.safetensors?download=true
150
+ https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/cuteyukimixAdorable_naiV3style.safetensors?download=true
151
+ https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/ddicon_v10.ckpt?download=true
152
+ https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/meinamix_meinaV11.safetensors?download=true
153
+ https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/meinapastel_v6-inpainting.safetensors?download=true
154
+ https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/meinapastel_v6Pastel.safetensors?download=true
155
+ https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/midjourney_20230624181825.safetensors?download=true
156
+ https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/mixProV4_v4.safetensors?download=true
157
+ https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/qteamixQ_omegaFp16.safetensors?download=true
158
+ https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/uberRealisticPornMerge_urpmv13.safetensors?download=true
159
+ https://huggingface.co/datasets/ACCA225/kagglemodel/resolve/main/kaggle/temp/velaMix_velaMixVersion2.safetensors?download=true
160
+ """
161
+
162
+ # 使用字符串的splitlines方法将字符串分割成列表
163
+ urls_list = download_urls.strip().splitlines()
164
+
165
+ # 调用函数开始下载
166
+ download_with_aria2(urls_list)
167
+ #sdmodel()
168
+ def mkdirs(path, exist_ok=True):
169
+ if path and not Path(path).exists():
170
+ os.makedirs(path,exist_ok=exist_ok)
171
+ plugins = [
172
+ "https://gitcode.net/overbill1683/stable-diffusion-webui-localization-zh_Hans",
173
+ #"https://gitcode.net/ranting8323/multidiffusion-upscaler-for-automatic1111",
174
+ "https://gitcode.net/ranting8323/adetailer",
175
+ "https://gitcode.net/ranting8323/sd-webui-inpaint-anything",
176
+ "https://gitcode.net/ranting8323/a1111-sd-webui-tagcomplete",
177
+ "https://gitcode.net/nightaway/sd-webui-infinite-image-browsing",
178
+ "https://openi.pcl.ac.cn/2575044704/sd-extension-system-info",
179
+ "https://openi.pcl.ac.cn/2575044704/batchlinks-webui",
180
+ 'https://openi.pcl.ac.cn/2575044704/stable-diffusion-webui-localization-zh_CN',
181
+ 'https://openi.pcl.ac.cn/2575044704/sd-webui-lora-block-weight',
182
+ 'https://openi.pcl.ac.cn/2575044704/sd-skin-extension',
183
+ "https://kkgithub.com/thygate/stable-diffusion-webui-depthmap-script.git",
184
+ #"https://gitcode.net/ranting8323/sd-webui-controlnet",
185
+ #"https://kkgithub.com/SignalFlagZ/sd-webui-civbrowser.git",
186
+ #"https://kkgithub.com/continue-revolution/sd-webui-animatediff.git",
187
+ #"https://kkkkgithub.com/aigc-apps/sd-webui-EasyPhoto.git",
188
+ "https://kkgithub.com/Iyashinouta/sd-model-downloader.git",
189
+ "https://kkgithub.com/fkunn1326/openpose-editor.git",
190
+ "https://kkgithub.com/zero01101/openOutpaint-webUI-extension.git",
191
+ "https://kkgithub.com/LonicaMewinsky/gif2gif.git",
192
+ #"https://kkgithub.com/modelscope/facechain.git",
193
+ "https://openi.pcl.ac.cn/2575044704/sd-webui-controlnet",
194
+ "https://openi.pcl.ac.cn/2575044704/sd-webui-agent-scheduler",
195
+ "https://openi.pcl.ac.cn/2575044704/sd-webui-depth-lib"
196
+ ]
197
+ suffix_1 = "Nyan9"
198
+ suffix_2 = "BiliBili"
199
+ needed_extensions = [
200
+ "https://openi.pcl.ac.cn/2575044704/sd-extension-system-info",
201
+ "https://openi.pcl.ac.cn/2575044704/batchlinks-webui",
202
+ ]
203
+ os.system("rm -rf /home/xlab-app-center/stable-diffusion-webui/extensions/sd-webui-animatediff/")
204
+ for plugin in plugins:
205
+ os.system(f"git clone {plugin}")
206
+ #for plugin in needed_extensions:
207
+ # os.system(f"git clone {plugin}")
208
+ os.makedirs('/home/xlab-app-center/stable-diffusion-webui/models/adetailer', exist_ok=True)
209
+ os.chdir(f"/home/xlab-app-center/stable-diffusion-webui/models/adetailer")
210
+ os.system(f"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://hf-mirror.com/Bingsu/adetailer/resolve/main/hand_yolov8s.pt -d /home/xlab-app-center/stable-diffusion-webui/models/adetailer -o hand_yolov8s.pt")
211
+ os.system(f"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://hf-mirror.com/Bingsu/adetailer/resolve/main/hand_yolov8n.pt -d /home/xlab-app-center/stable-diffusion-webui/models/adetailer -o hand_yolov8n.pt")
212
+ os.system(f"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://hf-mirror.com/datasets/ACCC1380/private-model/resolve/main/kaggle/input/museum/131-half.safetensors -d /home/xlab-app-center/stable-diffusion-webui/models/Stable-diffusion -o [萌二次元]131-half.safetensors")
213
+ os.system(f"rm /home/xlab-app-center/stable-diffusion-webui/models/Stable-diffusion/*porn*.safetensors")
214
+
215
+ os.system(f"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://hf-mirror.com/datasets/ACCC1380/private-model/resolve/main/ba.safetensors -d /home/xlab-app-center/stable-diffusion-webui/models/Lora -o ba.safetensors")
216
+ os.system(f"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://hf-mirror.com/datasets/ACCC1380/private-model/resolve/main/racaco2.safetensors -d /home/xlab-app-center/stable-diffusion-webui/models/Lora -o racaco2.safetensors")
217
+ os.system(f"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://hf-mirror.com/coinz/Add-detail/resolve/main/add_detail.safetensors -d /home/xlab-app-center/stable-diffusion-webui/models/Lora -o add_detail.safetensors")
218
+ os.system(f"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://hf-mirror.com/datasets/VASVASVAS/vae/resolve/main/pastel-waifu-diffusion.vae.pt -d /home/xlab-app-center/stable-diffusion-webui/models/VAE -o pastel-waifu-diffusion.vae.pt")
219
+ # os.system(f"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://download.openxlab.org.cn/models/camenduru/sdxl-refiner-1.0/weight//sd_xl_refiner_1.0.safetensors -d /home/xlab-app-center/stable-diffusion-webui/models/Stable-diffusion -o sd_xl_refiner_1.0.safetensors")
220
+ # os.system(f"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://download.openxlab.org.cn/models/camenduru/cyber-realistic/weight//cyberrealistic_v32.safetensors -d /home/xlab-app-center/stable-diffusion-webui/models/Stable-diffusion -o cyberrealistic_v32.safetensors")
221
+ os.chdir(f"/home/xlab-app-center/stable-diffusion-webui")
222
+ print('webui launching...')
223
+ pwd_1 = ngrok_token + suffix_1
224
+ pwd_2 = _ngrok_token + suffix_2
225
+ package_envs = [
226
+ {"env": "STABLE_DIFFUSION_REPO", "url": os.environ.get('STABLE_DIFFUSION_REPO', "https://gitcode.net/overbill1683/stablediffusion")},
227
+ {"env": "STABLE_DIFFUSION_XL_REPO", "url": os.environ.get('STABLE_DIFFUSION_XL_REPO', "https://gitcode.net/overbill1683/generative-models")},
228
+ {"env": "K_DIFFUSION_REPO", "url": os.environ.get('K_DIFFUSION_REPO', "https://gitcode.net/overbill1683/k-diffusion")},
229
+ {"env": "CODEFORMER_REPO", "url": os.environ.get('CODEFORMER_REPO', "https://gitcode.net/overbill1683/CodeFormer")},
230
+ {"env": "BLIP_REPO", "url": os.environ.get('BLIP_REPO', "https://gitcode.net/overbill1683/BLIP")},
231
+ ]
232
+ os.environ["PIP_INDEX_URL"] = "https://mirrors.aliyun.com/pypi/simple/"
233
+ for i in package_envs:
234
+ os.environ[i["env"]] = i["url"]
235
+
236
+ import os
237
+ import time
238
+ import wandb
239
+ import nvidia_smi
240
+ import os
241
+ import time
242
+ import wandb
243
+
244
+ # nginx 反向代理配置文件
245
+ def echoToFile(content:str,path:str):
246
+ if path.find('/') >= 0:
247
+ _path = '/'.join(path.split('/')[:-1])
248
+ run(f'''mkdir -p {_path}''')
249
+ with open(path,'w') as sh:
250
+ sh.write(content)
251
+ # 检查网络
252
+ def check_service(host, port):
253
+ try:
254
+ socket.create_connection((host, port), timeout=5)
255
+ return True
256
+ except socket.error:
257
+ return False
258
+ def localProxy():
259
+ os.system('sudo apt install nginx -y')
260
+ download_file('https://huggingface.co/datasets/ACCA225/openxlab/resolve/main/proxy_nginx.conf', os.path.join(base_directory, 'proxy_nginx.conf'))
261
+ if not check_service('localhost',_server_port):
262
+ run(f'''nginx -c /home/xlab-app-center/stable-diffusion-webui/proxy_nginx.conf''')
263
+ run(f'''nginx -s reload''')
264
+
265
+ # WandB登录
266
+ os.system('wandb login 5c00964de1bb95ec1ab24869d4c523c59e0fb8e3')
267
+ nvidia_smi.nvmlInit()
268
+ # 初始化WandB项目
269
+ wandb.init(project="gpu-temperature-monitor")
270
+
271
+ import threading
272
+ import requests
273
+
274
+ def check_website(url):
275
+ try:
276
+ response = requests.get(url)
277
+ if response.status_code == 200:
278
+ print(f"The website {url} is accessible.")
279
+ else:
280
+ print(f"The website {url} returned status code: {response.status_code}")
281
+ notbook()
282
+ except requests.exceptions.RequestException as e:
283
+ print(f"An error occurred while trying to access {url}: {e}")
284
+
285
+ def run_check_periodically(url, interval):
286
+ check_website(url)
287
+ threading.Timer(interval, run_check_periodically, args=(url, interval)).start()
288
+
289
+
290
+ import os
291
+ import threading
292
+ import wandb
293
+ import time
294
+ def monitor_gpu():
295
+ while True:
296
  try:
297
+ # 获取 GPU 温度
298
+ handle = nvidia_smi.nvmlDeviceGetHandleByIndex(0) # 0 表示第一个 GPU
299
+ gpu_temperature = nvidia_smi.nvmlDeviceGetTemperature(handle, nvidia_smi.NVML_TEMPERATURE_GPU)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
300
 
301
+ # 获取 GPU 使用率
302
+ utilization = nvidia_smi.nvmlDeviceGetUtilizationRates(handle)
303
+ gpu_usage = utilization.gpu
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
 
305
+ # 使用 WandB 记录 GPU 温度和使用率
306
+ wandb.log({"GPU 温度": gpu_temperature, "GPU 使用率": gpu_usage})
 
 
 
 
 
 
 
 
307
 
308
+ except Exception as e:
309
+ print(f"Error: {e}")
 
310
 
311
+ time.sleep(60)
312
+ def zrok():
313
+ notbook()
314
 
315
+ #os.system("wget https://hf-mirror.com/datasets/ACCA225/frp-1/resolve/main/frpc")
316
+ #os.system("chmod +x ./frpc")
317
+ #os.system("./frpc -f bsnehoeds17ett71i2cr79ujoa7ndkxz:13738352 & ./frpc -f bsnehoeds17ett71i2cr79ujoa7ndkxz:13738353")
318
+ pass
 
 
 
 
 
 
319
 
320
+ _pwd_1 = base64.b64encode(pwd_1.encode()).decode()
321
+ _pwd_2 = base64.b64encode(pwd_2.encode()).decode()
 
322
 
323
+ apitoken = "{}:{}".format(_pwd_1, _pwd_2)
324
+ def start():
325
 
326
+ try:
327
+ #安装环境
328
+ os.system(f"python launch.py --api --xformers --exit --enable-insecure-extension-access --gradio-queue --disable-safe-unpickle")
329
  except Exception as e:
330
+ # 在这里处理异常的代码
331
+ print(f"启动SD发��错误: {e}")
332
+ try:
333
+ while True:
334
+ #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")
335
+ os.system(f"python launch.py --xformers --enable-insecure-extension-access --gradio-queue --disable-safe-unpickle --allow-code")
336
+ except Exception as e:
337
+ # 在这里处理异常的代码
338
+ print(f"启动SD发生错误: {e}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
 
340
+ # 实例保活
341
+ import time
342
 
343
+ def session_saver():
 
 
 
 
344
  try:
 
 
345
  import cupy as cp
346
  except ImportError:
347
+ print("cupy模块未安装,正在安装...")
348
+ try:
349
+ import pip
350
+ pip.main(['install', 'cupy'])
351
+ import cupy as cp
352
+ except ImportError:
353
+ print("无法安装模块,请确保已正确安装pip。")
354
+ return
355
+
356
+ while True:
357
+ for _ in range(11):
358
+ matrix_a = cp.random.rand(10000, 10000)
359
+ matrix_b = cp.random.rand(10000, 10000)
360
+ result = cp.dot(matrix_a, matrix_b)
361
+ print("实例保活:", result)
362
+ del matrix_a, matrix_b, result
363
+ cp.cuda.Stream.null.synchronize()
364
+ time.sleep(500)
365
+
366
+ #keepliving_thread = threading.Thread(target=session_saver)
367
+ net_thread = threading.Thread(target=zrok)
368
+
369
+ net_thread.start()
370
+ #keepliving_thread.start()
371
+
372
+ start_thread = threading.Thread(target=start)
373
+ start_thread.start()
374
+ # 要检测的网站
375
+ website_url = "https://surely-definite-monarch.ngrok-free.app"
376
+
377
+ # 间隔时间(秒)
378
+ interval = 1800
379
+
380
+ # 第一次立即运行一次
381
+ #run_check_periodically(website_url, interval)
382
+
383
+ monitor_gpu()
384
+
385
+ #keepliving_thread.join()
386
+ time.sleep(9999999)
387
+ except Exception as e:
388
+ print("执行这个线程的时候发生重大错误:", e)