Spaces:
Running
Running
stlaurentjr
commited on
Commit
•
64d2d9a
1
Parent(s):
683eb0e
Update scripts/mainrunpodA1111.py
Browse files- scripts/mainrunpodA1111.py +9 -41
scripts/mainrunpodA1111.py
CHANGED
@@ -26,9 +26,11 @@ def Deps(force_reinstall):
|
|
26 |
from subprocess import call
|
27 |
import venv
|
28 |
|
|
|
|
|
|
|
29 |
if not force_reinstall and os.path.exists('/usr/local/lib/python3.10/dist-packages/safetensors'):
|
30 |
# Активация виртуального окружения и обновление pip
|
31 |
-
activate_script = os.path.join(venv_dir, 'bin', 'activate')
|
32 |
call(f'/bin/bash -c "source {activate_script} && pip install --upgrade pip"', shell=True)
|
33 |
|
34 |
ntbks()
|
@@ -36,8 +38,10 @@ def Deps(force_reinstall):
|
|
36 |
os.environ['TORCH_HOME'] = '/workspace/cache/torch'
|
37 |
os.environ['PYTHONWARNINGS'] = 'ignore'
|
38 |
else:
|
|
|
|
|
39 |
|
40 |
-
#
|
41 |
requirements = """
|
42 |
fastapi==0.87.0
|
43 |
onnxruntime==1.13.1
|
@@ -64,14 +68,14 @@ def Deps(force_reinstall):
|
|
64 |
pyre-extensions==0.0.29
|
65 |
"""
|
66 |
|
67 |
-
# Запись требований в файл requirements.txt
|
68 |
with open("/workspace/requirements.txt", "w") as req_file:
|
69 |
req_file.write(requirements)
|
70 |
|
71 |
-
#
|
72 |
call(f'/bin/bash -c "source {activate_script} && pip install -r /workspace/requirements.txt"', shell=True)
|
73 |
|
74 |
call('pip install --root-user-action=ignore --disable-pip-version-check --no-deps -qq gdown PyWavelets numpy==1.23.5 accelerate==0.12.0 --force-reinstall', shell=True, stdout=open('/dev/null', 'w'))
|
|
|
75 |
if os.path.exists('deps'):
|
76 |
call("rm -r deps", shell=True)
|
77 |
if os.path.exists('diffusers'):
|
@@ -81,14 +85,6 @@ def Deps(force_reinstall):
|
|
81 |
call('mkdir cache', shell=True)
|
82 |
os.chdir('deps')
|
83 |
|
84 |
-
# Создание виртуального окружения
|
85 |
-
venv_dir = '/workspace/venv'
|
86 |
-
venv.create(venv_dir, with_pip=True)
|
87 |
-
|
88 |
-
# Активация виртуального окружения и обновление pip
|
89 |
-
activate_script = os.path.join(venv_dir, 'bin', 'activate')
|
90 |
-
call(f'/bin/bash -c "source {activate_script} && pip install --upgrade pip"', shell=True)
|
91 |
-
|
92 |
# Загрузка файла
|
93 |
dwn("https://huggingface.co/flix-k/sd_dependencies/resolve/80e5df1ca2fea4b1273a0162f3ad63c4a139193f/rnpddeps-t2.tar.zst", "/workspace/deps/rnpddeps-t2.tar.zst", "Installing dependencies")
|
94 |
|
@@ -110,7 +106,6 @@ def Deps(force_reinstall):
|
|
110 |
os.chdir('/workspace')
|
111 |
call("git clone --depth 1 -q --branch main https://github.com/TheLastBen/diffusers", shell=True, stdout=open('/dev/null', 'w'))
|
112 |
|
113 |
-
# Активация виртуального окружения и установка зависимостей
|
114 |
call(f'/bin/bash -c "source {activate_script} && pip install --root-user-action=ignore --disable-pip-version-check -qq gradio==3.41.2"', shell=True)
|
115 |
call(f'/bin/bash -c "source {activate_script} && pip install fastapi==0.87.0 onnxruntime==1.13.1 scipy==1.9.3 uvicorn==0.20.0"', shell=True)
|
116 |
call(f'/bin/bash -c "source {activate_script} && pip install rembg==2.0.30"', shell=True)
|
@@ -119,39 +114,12 @@ def Deps(force_reinstall):
|
|
119 |
os.environ['TORCH_HOME'] = '/workspace/cache/torch'
|
120 |
os.environ['PYTHONWARNINGS'] = 'ignore'
|
121 |
call("sed -i 's@text = _formatwarnmsg(msg)@text =\"\"@g' /usr/lib/python3.10/warnings.py", shell=True)
|
122 |
-
###
|
123 |
-
# if not force_reinstall and os.path.exists('/usr/local/lib/python3.10/dist-packages/safetensors'):
|
124 |
-
# ntbks()
|
125 |
-
# print('[1;32mModules and notebooks updated, dependencies already installed')
|
126 |
-
# os.environ['TORCH_HOME'] = '/workspace/cache/torch'
|
127 |
-
# os.environ['PYTHONWARNINGS'] = 'ignore'
|
128 |
-
# else:
|
129 |
-
# call('pip install --root-user-action=ignore --disable-pip-version-check --no-deps -qq gdown PyWavelets numpy==1.23.5 accelerate==0.12.0 --force-reinstall', shell=True, stdout=open('/dev/null', 'w'))
|
130 |
-
# ntbks()
|
131 |
-
# if os.path.exists('deps'):
|
132 |
-
# call("rm -r deps", shell=True)
|
133 |
-
# if os.path.exists('diffusers'):
|
134 |
-
# call("rm -r diffusers", shell=True)
|
135 |
-
# call('mkdir deps', shell=True)
|
136 |
-
# if not os.path.exists('cache'):
|
137 |
-
# call('mkdir cache', shell=True)
|
138 |
-
# os.chdir('deps')
|
139 |
-
# dwn("https://huggingface.co/flix-k/sd_dependencies/resolve/80e5df1ca2fea4b1273a0162f3ad63c4a139193f/rnpddeps-t2.tar.zst", "/workspace/deps/rnpd-310.tar.zst", "Installing dependencies")
|
140 |
-
# call('tar -C / --zstd -xf rnpddeps-t2.tar.zst', shell=True, stdout=open('/dev/null', 'w'))
|
141 |
-
# call("sed -i 's@~/.cache@/workspace/cache@' /usr/local/lib/python3.10/dist-packages/transformers/utils/hub.py", shell=True)
|
142 |
-
# os.chdir('/workspace')
|
143 |
-
# call("git clone --depth 1 -q --branch main https://github.com/TheLastBen/diffusers", shell=True, stdout=open('/dev/null', 'w'))
|
144 |
-
# call('pip install --root-user-action=ignore --disable-pip-version-check -qq gradio==3.41.2', shell=True, stdout=open('/dev/null', 'w'))
|
145 |
-
# call("rm -r deps", shell=True)
|
146 |
-
# os.chdir('/workspace')
|
147 |
-
# os.environ['TORCH_HOME'] = '/workspace/cache/torch'
|
148 |
-
# os.environ['PYTHONWARNINGS'] = 'ignore'
|
149 |
-
# call("sed -i 's@text = _formatwarnmsg(msg)@text =\"\"@g' /usr/lib/python3.10/warnings.py", shell=True)
|
150 |
clear_output()
|
151 |
|
152 |
done()
|
153 |
|
154 |
|
|
|
155 |
def dwn(url, dst, msg):
|
156 |
file_size = None
|
157 |
req = Request(url, headers={"User-Agent": "torch.hub"})
|
|
|
26 |
from subprocess import call
|
27 |
import venv
|
28 |
|
29 |
+
venv_dir = '/workspace/venv'
|
30 |
+
activate_script = os.path.join(venv_dir, 'bin', 'activate')
|
31 |
+
|
32 |
if not force_reinstall and os.path.exists('/usr/local/lib/python3.10/dist-packages/safetensors'):
|
33 |
# Активация виртуального окружения и обновление pip
|
|
|
34 |
call(f'/bin/bash -c "source {activate_script} && pip install --upgrade pip"', shell=True)
|
35 |
|
36 |
ntbks()
|
|
|
38 |
os.environ['TORCH_HOME'] = '/workspace/cache/torch'
|
39 |
os.environ['PYTHONWARNINGS'] = 'ignore'
|
40 |
else:
|
41 |
+
# Создание виртуального окружения
|
42 |
+
venv.create(venv_dir, with_pip=True)
|
43 |
|
44 |
+
# Запись требований в файл requirements.txt
|
45 |
requirements = """
|
46 |
fastapi==0.87.0
|
47 |
onnxruntime==1.13.1
|
|
|
68 |
pyre-extensions==0.0.29
|
69 |
"""
|
70 |
|
|
|
71 |
with open("/workspace/requirements.txt", "w") as req_file:
|
72 |
req_file.write(requirements)
|
73 |
|
74 |
+
# Активация виртуального окружения и установка зависимостей из файла requirements.txt
|
75 |
call(f'/bin/bash -c "source {activate_script} && pip install -r /workspace/requirements.txt"', shell=True)
|
76 |
|
77 |
call('pip install --root-user-action=ignore --disable-pip-version-check --no-deps -qq gdown PyWavelets numpy==1.23.5 accelerate==0.12.0 --force-reinstall', shell=True, stdout=open('/dev/null', 'w'))
|
78 |
+
|
79 |
if os.path.exists('deps'):
|
80 |
call("rm -r deps", shell=True)
|
81 |
if os.path.exists('diffusers'):
|
|
|
85 |
call('mkdir cache', shell=True)
|
86 |
os.chdir('deps')
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
# Загрузка файла
|
89 |
dwn("https://huggingface.co/flix-k/sd_dependencies/resolve/80e5df1ca2fea4b1273a0162f3ad63c4a139193f/rnpddeps-t2.tar.zst", "/workspace/deps/rnpddeps-t2.tar.zst", "Installing dependencies")
|
90 |
|
|
|
106 |
os.chdir('/workspace')
|
107 |
call("git clone --depth 1 -q --branch main https://github.com/TheLastBen/diffusers", shell=True, stdout=open('/dev/null', 'w'))
|
108 |
|
|
|
109 |
call(f'/bin/bash -c "source {activate_script} && pip install --root-user-action=ignore --disable-pip-version-check -qq gradio==3.41.2"', shell=True)
|
110 |
call(f'/bin/bash -c "source {activate_script} && pip install fastapi==0.87.0 onnxruntime==1.13.1 scipy==1.9.3 uvicorn==0.20.0"', shell=True)
|
111 |
call(f'/bin/bash -c "source {activate_script} && pip install rembg==2.0.30"', shell=True)
|
|
|
114 |
os.environ['TORCH_HOME'] = '/workspace/cache/torch'
|
115 |
os.environ['PYTHONWARNINGS'] = 'ignore'
|
116 |
call("sed -i 's@text = _formatwarnmsg(msg)@text =\"\"@g' /usr/lib/python3.10/warnings.py", shell=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
clear_output()
|
118 |
|
119 |
done()
|
120 |
|
121 |
|
122 |
+
|
123 |
def dwn(url, dst, msg):
|
124 |
file_size = None
|
125 |
req = Request(url, headers={"User-Agent": "torch.hub"})
|