Spaces:
Sleeping
Sleeping
| FROM nvidia/cuda:12.1.1-devel-ubuntu22.04 | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| ENV TORCH_CUDA_ARCH_LIST="7.5" | |
| ENV PYTHONUNBUFFERED=1 | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| # 1. System dependencies + Python 3.10 | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| software-properties-common \ | |
| && add-apt-repository ppa:deadsnakes/ppa \ | |
| && apt-get update && apt-get install -y --no-install-recommends \ | |
| python3.10 python3.10-dev python3.10-venv python3.10-distutils \ | |
| git wget curl build-essential cmake \ | |
| libgl1-mesa-glx libglib2.0-0 libsm6 libxrender1 libxext6 \ | |
| libgomp1 libglu1-mesa libxi6 libxmu6 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Make python3.10 the default | |
| RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1 \ | |
| && update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1 \ | |
| && curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10 | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| # 2. PyTorch 2.4.0+cu121 (pin FIRST) | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| RUN pip install --no-cache-dir \ | |
| torch==2.4.0 torchvision==0.19.0 \ | |
| --index-url https://download.pytorch.org/whl/cu121 | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| # 3. setup.sh --basic deps | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| # Remove system-installed blinker (distutils) that blocks pip upgrades | |
| RUN pip install --no-cache-dir --ignore-installed blinker \ | |
| && pip install --no-cache-dir \ | |
| pillow imageio imageio-ffmpeg tqdm easydict \ | |
| opencv-python-headless scipy ninja \ | |
| rembg onnxruntime trimesh open3d xatlas \ | |
| pyvista pymeshfix igraph \ | |
| transformers scikit-image einops safetensors \ | |
| huggingface-hub | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| # 4. utils3d (pinned commit) | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| RUN pip install --no-cache-dir \ | |
| git+https://github.com/EasternJournalist/utils3d.git@9a4eb15e4021b67b12c460c7057d642626897ec8 | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| # 5. spconv-cu120 | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| RUN pip install --no-cache-dir spconv-cu120 | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| # 6. xformers 0.0.27.post2 (cu121) | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| RUN pip install --no-cache-dir \ | |
| xformers==0.0.27.post2 \ | |
| --index-url https://download.pytorch.org/whl/cu121 | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| # 7. kaolin (torch-2.4.0 cu121) | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| RUN pip install --no-cache-dir kaolin \ | |
| --find-links https://nvidia-kaolin.s3.us-east-2.amazonaws.com/torch-2.4.0_cu121.html | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| # 8. Pre-built CUDA wheels (built on Colab to avoid OOM on HF build machine) | |
| # Requires: nvdiffrast, diffoctreerast, diff_gaussian_rasterization | |
| # See scene_generation/03_build_wheels.ipynb to rebuild | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| COPY wheels/*.whl /tmp/wheels/ | |
| RUN pip install --no-cache-dir /tmp/wheels/*.whl && rm -rf /tmp/wheels | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| # 9. numpy pin + FastAPI (replaces gradio to avoid transitive dep hell) | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| RUN pip install --no-cache-dir \ | |
| numpy==1.26.4 \ | |
| fastapi uvicorn python-multipart | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| # 10. Clone SceneGen repo | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| RUN git clone https://github.com/Mengmouxu/SceneGen.git /opt/SceneGen | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| # 11. Download checkpoints (baked into image) | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| RUN python -c "\ | |
| from huggingface_hub import snapshot_download; \ | |
| snapshot_download(repo_id='facebook/VGGT-1B', local_dir='/opt/SceneGen/checkpoints/VGGT-1B'); \ | |
| snapshot_download(repo_id='haoningwu/SceneGen', local_dir='/opt/SceneGen/checkpoints/scenegen'); \ | |
| " | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| # 12. HF Space user setup | |
| # ββββββββββββββββββββββββββββββββββββββββββββββ | |
| RUN useradd -m -u 1000 user \ | |
| && chown -R user:user /opt/SceneGen | |
| USER user | |
| ENV HOME=/home/user | |
| WORKDIR /home/user/app | |
| COPY --chown=user:user app.py . | |
| CMD ["python", "app.py"] | |