Spaces:
Sleeping
Sleeping
Fix CUDA to 12.2.
Browse files- README.md +4 -1
- app.py +32 -5
- requirements.txt +2 -3
README.md
CHANGED
|
@@ -15,5 +15,8 @@ Official demo for **[CityDreamer: Compositional Generative Model of Unbounded 3D
|
|
| 15 |
- 🤗 Try CityDreamer to generate photolistic 3D cities.
|
| 16 |
- ⚠️ Due to the limited computational resources at Hugging Face, this demo only generates **A SINGLE IMAGE** based on the New York City layout. If you wish to experience more comprehensive functionality, please visit the demo on [GitHub](https://github.com/hzxie/city-dreamer?tab=readme-ov-file#iterative-demo-%EF%B8%8F).
|
| 17 |
|
| 18 |
-
<p style="color:red"
|
|
|
|
|
|
|
|
|
|
| 19 |
|
|
|
|
| 15 |
- 🤗 Try CityDreamer to generate photolistic 3D cities.
|
| 16 |
- ⚠️ Due to the limited computational resources at Hugging Face, this demo only generates **A SINGLE IMAGE** based on the New York City layout. If you wish to experience more comprehensive functionality, please visit the demo on [GitHub](https://github.com/hzxie/city-dreamer?tab=readme-ov-file#iterative-demo-%EF%B8%8F).
|
| 17 |
|
| 18 |
+
<p style="color:red">
|
| 19 |
+
❕IMPORTANT NOTE: The HF team and we are currently working on migrating to ZeroGPU, so the demo may be temporarily unavailable.<br>
|
| 20 |
+
Track the debugging progress on <a href="https://huggingface.co/spaces/zero-gpu-explorers/README/discussions/111">the community of zero-gpu-explorers</a>.
|
| 21 |
+
</p>
|
| 22 |
|
app.py
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
# @Author: Haozhe Xie
|
| 5 |
# @Date: 2024-03-02 16:30:00
|
| 6 |
# @Last Modified by: Haozhe Xie
|
| 7 |
-
# @Last Modified at: 2024-09-22
|
| 8 |
# @Email: [email protected]
|
| 9 |
|
| 10 |
import gradio as gr
|
|
@@ -12,15 +12,39 @@ import logging
|
|
| 12 |
import numpy as np
|
| 13 |
import os
|
| 14 |
|
| 15 |
-
import spaces
|
| 16 |
import ssl
|
| 17 |
import subprocess
|
| 18 |
import sys
|
| 19 |
-
import torch
|
| 20 |
import urllib.request
|
| 21 |
|
| 22 |
from PIL import Image
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
# Fix: ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
|
| 25 |
ssl._create_default_https_context = ssl._create_unverified_context
|
| 26 |
# Import CityDreamer modules
|
|
@@ -43,7 +67,7 @@ def install_cuda_toolkit():
|
|
| 43 |
subprocess.call(["wget", "-q", CUDA_TOOLKIT_URL, "-O", CUDA_TOOLKIT_FILE])
|
| 44 |
subprocess.call(["chmod", "+x", CUDA_TOOLKIT_FILE])
|
| 45 |
subprocess.call([CUDA_TOOLKIT_FILE, "--silent", "--toolkit"])
|
| 46 |
-
|
| 47 |
os.environ["CUDA_HOME"] = "/usr/local/cuda"
|
| 48 |
os.environ["PATH"] = "%s/bin:%s" % (os.environ["CUDA_HOME"], os.environ["PATH"])
|
| 49 |
os.environ["LD_LIBRARY_PATH"] = "%s/lib:%s" % (
|
|
@@ -61,7 +85,9 @@ def setup_runtime_env():
|
|
| 61 |
logging.info("CUDA is available: %s" % torch.cuda.is_available())
|
| 62 |
logging.info("CUDA Device Capability: %s" % (torch.cuda.get_device_capability(),))
|
| 63 |
|
| 64 |
-
# Install Pre-compiled CUDA extensions
|
|
|
|
|
|
|
| 65 |
# ext_dir = os.path.join(os.path.dirname(__file__), "wheels")
|
| 66 |
# for e in os.listdir(ext_dir):
|
| 67 |
# logging.info("Installing Extensions from %s" % e)
|
|
@@ -154,6 +180,7 @@ if __name__ == "__main__":
|
|
| 154 |
logging.basicConfig(
|
| 155 |
format="[%(levelname)s] %(asctime)s %(message)s", level=logging.INFO
|
| 156 |
)
|
|
|
|
| 157 |
if _get_output(["nvcc", "--version"]) is None:
|
| 158 |
logging.info("Installing CUDA toolkit...")
|
| 159 |
install_cuda_toolkit()
|
|
|
|
| 4 |
# @Author: Haozhe Xie
|
| 5 |
# @Date: 2024-03-02 16:30:00
|
| 6 |
# @Last Modified by: Haozhe Xie
|
| 7 |
+
# @Last Modified at: 2024-09-22 21:11:51
|
| 8 |
# @Email: [email protected]
|
| 9 |
|
| 10 |
import gradio as gr
|
|
|
|
| 12 |
import numpy as np
|
| 13 |
import os
|
| 14 |
|
|
|
|
| 15 |
import ssl
|
| 16 |
import subprocess
|
| 17 |
import sys
|
|
|
|
| 18 |
import urllib.request
|
| 19 |
|
| 20 |
from PIL import Image
|
| 21 |
|
| 22 |
+
# Reinstall PyTorch with CUDA 11.8 (Default version is 12.1)
|
| 23 |
+
# subprocess.call(
|
| 24 |
+
# [
|
| 25 |
+
# "pip",
|
| 26 |
+
# "install",
|
| 27 |
+
# "torch==2.2.2",
|
| 28 |
+
# "torchvision==0.17.2",
|
| 29 |
+
# "--index-url",
|
| 30 |
+
# "https://download.pytorch.org/whl/cu118",
|
| 31 |
+
# ]
|
| 32 |
+
# )
|
| 33 |
+
import torch
|
| 34 |
+
|
| 35 |
+
# Create a dummy decorator for Non-ZeroGPU environments
|
| 36 |
+
if os.environ.get("SPACES_ZERO_GPU") is not None:
|
| 37 |
+
import spaces
|
| 38 |
+
else:
|
| 39 |
+
class spaces:
|
| 40 |
+
@staticmethod
|
| 41 |
+
def GPU(func):
|
| 42 |
+
# This is a dummy wrapper that just calls the function.
|
| 43 |
+
def wrapper(*args, **kwargs):
|
| 44 |
+
return func(*args, **kwargs)
|
| 45 |
+
|
| 46 |
+
return wrapper
|
| 47 |
+
|
| 48 |
# Fix: ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
|
| 49 |
ssl._create_default_https_context = ssl._create_unverified_context
|
| 50 |
# Import CityDreamer modules
|
|
|
|
| 67 |
subprocess.call(["wget", "-q", CUDA_TOOLKIT_URL, "-O", CUDA_TOOLKIT_FILE])
|
| 68 |
subprocess.call(["chmod", "+x", CUDA_TOOLKIT_FILE])
|
| 69 |
subprocess.call([CUDA_TOOLKIT_FILE, "--silent", "--toolkit"])
|
| 70 |
+
|
| 71 |
os.environ["CUDA_HOME"] = "/usr/local/cuda"
|
| 72 |
os.environ["PATH"] = "%s/bin:%s" % (os.environ["CUDA_HOME"], os.environ["PATH"])
|
| 73 |
os.environ["LD_LIBRARY_PATH"] = "%s/lib:%s" % (
|
|
|
|
| 85 |
logging.info("CUDA is available: %s" % torch.cuda.is_available())
|
| 86 |
logging.info("CUDA Device Capability: %s" % (torch.cuda.get_device_capability(),))
|
| 87 |
|
| 88 |
+
# Install Pre-compiled CUDA extensions (Not working)
|
| 89 |
+
# Ref: https://huggingface.co/spaces/zero-gpu-explorers/README/discussions/110
|
| 90 |
+
#
|
| 91 |
# ext_dir = os.path.join(os.path.dirname(__file__), "wheels")
|
| 92 |
# for e in os.listdir(ext_dir):
|
| 93 |
# logging.info("Installing Extensions from %s" % e)
|
|
|
|
| 180 |
logging.basicConfig(
|
| 181 |
format="[%(levelname)s] %(asctime)s %(message)s", level=logging.INFO
|
| 182 |
)
|
| 183 |
+
logging.info("Environment Variables: %s" % os.environ)
|
| 184 |
if _get_output(["nvcc", "--version"]) is None:
|
| 185 |
logging.info("Installing CUDA toolkit...")
|
| 186 |
install_cuda_toolkit()
|
requirements.txt
CHANGED
|
@@ -1,8 +1,7 @@
|
|
| 1 |
-
torch==2.2.2
|
| 2 |
-
torchvision==0.17.2
|
| 3 |
-
|
| 4 |
easydict
|
| 5 |
gradio
|
| 6 |
numpy<2.0.0
|
| 7 |
opencv-python
|
| 8 |
pillow
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
easydict
|
| 2 |
gradio
|
| 3 |
numpy<2.0.0
|
| 4 |
opencv-python
|
| 5 |
pillow
|
| 6 |
+
torch==2.2.2
|
| 7 |
+
torchvision==0.17.2
|