File size: 1,917 Bytes
58eb3d4 17319a1 064ee96 d63dffd c67171e 064ee96 d5e87bc 58eb3d4 17319a1 58eb3d4 17319a1 58eb3d4 17319a1 58eb3d4 17319a1 58eb3d4 17319a1 c67171e 58eb3d4 17319a1 d5e87bc c67171e 58eb3d4 17319a1 58eb3d4 17319a1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | # Use an official PyTorch image WITH CUDA development headers required for compiling
FROM pytorch/pytorch:2.1.2-cuda12.1-cudnn8-devel
# Prevent interactive prompts during apt-get installations
ENV DEBIAN_FRONTEND=noninteractive
# Tell PyTorch which GPU architectures to compile for explicitly
ENV TORCH_CUDA_ARCH_LIST="7.5 8.0 8.6 8.9 9.0"
# 🛑 THE FIX: Throttle the compiler to prevent Out Of Memory (OOMKilled) crashes
ENV MAX_JOBS=2
# Set the working directory
WORKDIR /app
# Install system dependencies for C++/CUDA extensions, 3D processing, and SSH access
RUN apt-get update && apt-get install -y \
git \
build-essential \
ninja-build \
libgl1 \
libglib2.0-0 \
tmate \
openssh-client \
&& rm -rf /var/lib/apt/lists/*
# Clone the official Hunyuan3D-2 repository
RUN git clone https://github.com/Tencent/Hunyuan3D-2.git /app/Hunyuan3D-2
# Install the base Python requirements from the Tencent repository FIRST
RUN pip install --no-cache-dir -r /app/Hunyuan3D-2/requirements.txt
# Copy your local requirements and install them
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Explicitly force NumPy to stay below 2.0 right before compiling
RUN pip install --no-cache-dir "numpy<2"
# Compile the Custom Rasterizer (Required for Textures)
WORKDIR /app/Hunyuan3D-2/hy3dgen/texgen/custom_rasterizer
RUN python setup.py install
# Compile the Differentiable Renderer (Required for Textures)
WORKDIR /app/Hunyuan3D-2/hy3dgen/texgen/differentiable_renderer
RUN python setup.py install
# Move back to the root app directory
WORKDIR /app
# Copy your API script into the container
COPY app.py .
# Create a directory to store generated outputs temporarily
RUN mkdir -p /app/outputs
# Expose the default Hugging Face Spaces port
EXPOSE 7860
# Command to start the FastAPI application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |