Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import spaces
|
2 |
import os
|
3 |
-
os.environ["CXX"] = os.popen("which g++").read().strip()
|
4 |
-
os.environ["CC"] = os.popen("which gcc").read().strip()
|
5 |
os.environ['CUDA_LAUNCH_BLOCKING']="1"
|
6 |
os.environ['TORCH_USE_CUDA_DSA'] = "1"
|
7 |
import nvdiffrast.torch as dr
|
@@ -37,12 +37,11 @@ def install_cuda_toolkit():
|
|
37 |
CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run"
|
38 |
# CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/12.2.0/local_installers/cuda_12.2.0_535.54.03_linux.run"
|
39 |
# CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/12.1.0/local_installers/cuda_12.1.0_530.30.02_linux.run"
|
40 |
-
print(f"==> install cuda {CUDA_TOOLKIT_URL}")
|
41 |
CUDA_TOOLKIT_FILE = "/tmp/%s" % os.path.basename(CUDA_TOOLKIT_URL)
|
42 |
subprocess.call(["wget", "-q", CUDA_TOOLKIT_URL, "-O", CUDA_TOOLKIT_FILE])
|
43 |
subprocess.call(["chmod", "+x", CUDA_TOOLKIT_FILE])
|
44 |
subprocess.call([CUDA_TOOLKIT_FILE, "--silent", "--toolkit"])
|
45 |
-
|
46 |
os.environ["CUDA_HOME"] = "/usr/local/cuda"
|
47 |
os.environ["PATH"] = "%s/bin:%s" % (os.environ["CUDA_HOME"], os.environ["PATH"])
|
48 |
os.environ["LD_LIBRARY_PATH"] = "%s/lib:%s" % (
|
@@ -88,7 +87,7 @@ else:
|
|
88 |
# os.environ["CUDA_HOME"] = "/usr/local/cuda"
|
89 |
# os.environ["PATH"] += os.pathsep + os.path.join(os.environ["CUDA_HOME"], "bin")
|
90 |
# os.environ["LD_LIBRARY_PATH"] = os.environ.get("LD_LIBRARY_PATH", "") + os.pathsep + os.path.join(os.environ["CUDA_HOME"], "lib64")
|
91 |
-
|
92 |
print(f"GPU: {torch.cuda.is_available()}")
|
93 |
if torch.cuda.is_available() and torch.cuda.device_count() >= 2:
|
94 |
device0 = torch.device('cuda:0')
|
@@ -286,9 +285,6 @@ state_dict = {k[14:]: v for k, v in state_dict.items() if k.startswith('lrm_gene
|
|
286 |
model.load_state_dict(state_dict, strict=True)
|
287 |
|
288 |
model = model.to(device)
|
289 |
-
if IS_FLEXICUBES:
|
290 |
-
model.init_flexicubes_geometry(device, fovy=30.0, use_renderer=False)
|
291 |
-
model = model.eval()
|
292 |
|
293 |
print('Loading Finished!')
|
294 |
|
@@ -356,7 +352,10 @@ def make_mesh(mesh_fpath, planes):
|
|
356 |
|
357 |
@spaces.GPU
|
358 |
def make3d(images):
|
359 |
-
|
|
|
|
|
|
|
360 |
images = np.asarray(images, dtype=np.float32) / 255.0
|
361 |
images = torch.from_numpy(images).permute(2, 0, 1).contiguous().float() # (3, 960, 640)
|
362 |
images = rearrange(images, 'c (n h) (m w) -> (n m) c h w', n=3, m=2) # (6, 3, 320, 320)
|
|
|
1 |
import spaces
|
2 |
import os
|
3 |
+
# os.environ["CXX"] = os.popen("which g++").read().strip()
|
4 |
+
# os.environ["CC"] = os.popen("which gcc").read().strip()
|
5 |
os.environ['CUDA_LAUNCH_BLOCKING']="1"
|
6 |
os.environ['TORCH_USE_CUDA_DSA'] = "1"
|
7 |
import nvdiffrast.torch as dr
|
|
|
37 |
CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run"
|
38 |
# CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/12.2.0/local_installers/cuda_12.2.0_535.54.03_linux.run"
|
39 |
# CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/12.1.0/local_installers/cuda_12.1.0_530.30.02_linux.run"
|
|
|
40 |
CUDA_TOOLKIT_FILE = "/tmp/%s" % os.path.basename(CUDA_TOOLKIT_URL)
|
41 |
subprocess.call(["wget", "-q", CUDA_TOOLKIT_URL, "-O", CUDA_TOOLKIT_FILE])
|
42 |
subprocess.call(["chmod", "+x", CUDA_TOOLKIT_FILE])
|
43 |
subprocess.call([CUDA_TOOLKIT_FILE, "--silent", "--toolkit"])
|
44 |
+
|
45 |
os.environ["CUDA_HOME"] = "/usr/local/cuda"
|
46 |
os.environ["PATH"] = "%s/bin:%s" % (os.environ["CUDA_HOME"], os.environ["PATH"])
|
47 |
os.environ["LD_LIBRARY_PATH"] = "%s/lib:%s" % (
|
|
|
87 |
# os.environ["CUDA_HOME"] = "/usr/local/cuda"
|
88 |
# os.environ["PATH"] += os.pathsep + os.path.join(os.environ["CUDA_HOME"], "bin")
|
89 |
# os.environ["LD_LIBRARY_PATH"] = os.environ.get("LD_LIBRARY_PATH", "") + os.pathsep + os.path.join(os.environ["CUDA_HOME"], "lib64")
|
90 |
+
|
91 |
print(f"GPU: {torch.cuda.is_available()}")
|
92 |
if torch.cuda.is_available() and torch.cuda.device_count() >= 2:
|
93 |
device0 = torch.device('cuda:0')
|
|
|
285 |
model.load_state_dict(state_dict, strict=True)
|
286 |
|
287 |
model = model.to(device)
|
|
|
|
|
|
|
288 |
|
289 |
print('Loading Finished!')
|
290 |
|
|
|
352 |
|
353 |
@spaces.GPU
|
354 |
def make3d(images):
|
355 |
+
global model
|
356 |
+
if IS_FLEXICUBES:
|
357 |
+
model.init_flexicubes_geometry(device, fovy=30.0, use_renderer=False)
|
358 |
+
model = model.eval()
|
359 |
images = np.asarray(images, dtype=np.float32) / 255.0
|
360 |
images = torch.from_numpy(images).permute(2, 0, 1).contiguous().float() # (3, 960, 640)
|
361 |
images = rearrange(images, 'c (n h) (m w) -> (n m) c h w', n=3, m=2) # (6, 3, 320, 320)
|