aakashimagine commited on
Commit
ae20a97
·
1 Parent(s): 3dd586b

added texture fix

Browse files
Files changed (1) hide show
  1. gradio_app.py +71 -0
gradio_app.py CHANGED
@@ -150,6 +150,77 @@ else:
150
  This allows code that uses the `spaces.GPU` decorator to run without modification locally.
151
  """
152
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  class spaces:
154
  class GPU:
155
  def __init__(self, duration=60):
 
150
  This allows code that uses the `spaces.GPU` decorator to run without modification locally.
151
  """
152
 
153
+ import os, spaces, subprocess, sys, shlex
154
+
155
+ def install_cuda_toolkit():
156
+ # CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run"
157
+ CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/12.2.0/local_installers/cuda_12.2.0_535.54.03_linux.run"
158
+ CUDA_TOOLKIT_FILE = "/tmp/%s" % os.path.basename(CUDA_TOOLKIT_URL)
159
+ subprocess.call(["wget", "-q", CUDA_TOOLKIT_URL, "-O", CUDA_TOOLKIT_FILE])
160
+ subprocess.call(["chmod", "+x", CUDA_TOOLKIT_FILE])
161
+ subprocess.call([CUDA_TOOLKIT_FILE, "--silent", "--toolkit"])
162
+
163
+ os.environ["CUDA_HOME"] = "/usr/local/cuda"
164
+ os.environ["PATH"] = "%s/bin:%s" % (os.environ["CUDA_HOME"], os.environ["PATH"])
165
+ os.environ["LD_LIBRARY_PATH"] = "%s/lib:%s" % (
166
+ os.environ["CUDA_HOME"],
167
+ ""
168
+ if "LD_LIBRARY_PATH" not in os.environ
169
+ else os.environ["LD_LIBRARY_PATH"],
170
+ )
171
+ # Fix: arch_list[-1] += '+PTX'; IndexError: list index out of range
172
+ os.environ["TORCH_CUDA_ARCH_LIST"] = "8.0;8.6"
173
+
174
+ def prepare_env():
175
+ # print('install custom')
176
+ # os.system(f"cd /home/user/app/hy3dpaint/custom_rasterizer && {pythonpath} -m pip install -e .")
177
+ # os.system(f"cd /home/user/app/hy3dpaint/packages/custom_rasterizer && pip install -e .")
178
+ subprocess.run(
179
+ shlex.split(
180
+ "pip install custom_rasterizer-0.1-cp310-cp310-linux_x86_64.whl"
181
+ ),
182
+ check=True,
183
+ )
184
+
185
+ print(
186
+ "cd /home/user/app/hy3dpaint/differentiable_renderer/ && bash compile_mesh_painter.sh"
187
+ )
188
+ os.system(
189
+ "cd /home/user/app/hy3dpaint/DifferentiableRenderer && bash compile_mesh_painter.sh"
190
+ )
191
+ # print("wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth -P /home/user/app/hy3dpaint/ckpt")
192
+ # os.system("wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth -P /home/user/app/hy3dpaint/ckpt")
193
+
194
+ def check():
195
+ import custom_rasterizer
196
+
197
+ print(type(custom_rasterizer))
198
+ print(dir(custom_rasterizer))
199
+ print(getattr(custom_rasterizer, "__file__", None))
200
+
201
+ package_dir = None
202
+ if hasattr(custom_rasterizer, "__file__") and custom_rasterizer.__file__:
203
+ package_dir = os.path.dirname(custom_rasterizer.__file__)
204
+ elif hasattr(custom_rasterizer, "__path__"):
205
+ package_dir = list(custom_rasterizer.__path__)[0]
206
+ else:
207
+ raise RuntimeError("Cannot determine package path")
208
+ print(package_dir)
209
+
210
+ for root, dirs, files in os.walk(package_dir):
211
+ level = root.replace(package_dir, "").count(os.sep)
212
+ indent = " " * 4 * level
213
+ print(f"{indent}{os.path.basename(root)}/")
214
+ subindent = " " * 4 * (level + 1)
215
+ for f in files:
216
+ print(f"{subindent}{f}")
217
+
218
+ # print(torch.__version__)
219
+ # install_cuda_toolkit()
220
+ print(torch.__version__)
221
+ prepare_env()
222
+ check()
223
+
224
  class spaces:
225
  class GPU:
226
  def __init__(self, duration=60):