Spaces:
Paused
Paused
FROM pytorch/pytorch:2.1.0-cuda12.1-cudnn8-runtime | |
ENV DEBIAN_FRONTEND=noninteractive | |
ENV MKL_THREADING_LAYER=GNU | |
# Install dependencies | |
RUN apt-get update && apt-get install -y \ | |
git wget libgl1-mesa-glx libglib2.0-0 ffmpeg libx264-dev pkg-config \ | |
build-essential cmake g++ software-properties-common \ | |
gnupg2 libopenblas-dev libx11-dev && \ | |
rm -rf /var/lib/apt/lists/* | |
# Add NVIDIA package repositories | |
RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb && \ | |
dpkg -i cuda-keyring_1.1-1_all.deb && \ | |
apt-get update | |
# Install CUDA Toolkit and cuDNN (with version matching the base image) | |
RUN apt-get install -y cuda-toolkit-12-1 libcudnn8 libcudnn8-dev | |
# Set CUDA paths for build environment | |
ENV PATH=/usr/local/cuda/bin:$PATH \ | |
CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda \ | |
CUDA_HOME=/usr/local/cuda \ | |
LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH \ | |
CMAKE_PREFIX_PATH="/usr/local/cuda:/usr/lib/x86_64-linux-gnu/" \ | |
TORCH_CUDA_ARCH_LIST="7.0;7.5;8.0;8.6;8.9;9.0" | |
# Upgrade pip & install dependencies | |
RUN pip install --upgrade pip setuptools wheel | |
RUN pip install --no-cache-dir urllib3 transformers yacs scipy scikit-image scikit-learn PyYAML Pillow "numpy<2" opencv-python imageio ffmpeg-python av "moviepy<2" gradio cmake | |
# Create app directory structure first | |
RUN mkdir -p /app/checkpoints | |
# Clone the repository | |
RUN git clone -b dev https://github.com/fffiloni/dreamtalk /app | |
# Download model checkpoints | |
RUN wget https://huggingface.co/camenduru/dreamtalk/resolve/main/damo/dreamtalk/checkpoints/denoising_network.pth -O /app/checkpoints/denoising_network.pth && \ | |
wget https://huggingface.co/camenduru/dreamtalk/resolve/main/damo/dreamtalk/checkpoints/renderer.pt -O /app/checkpoints/renderer.pt | |
# Explicitly set environment variables for dlib compilation | |
ENV DLIB_USE_CUDA=1 \ | |
DLIB_JPEG_SUPPORT=1 \ | |
DLIB_PNG_SUPPORT=1 | |
# Install dlib with CUDA support | |
RUN pip install --no-cache-dir dlib==19.24.0 | |
# Create a user and set ownership | |
RUN useradd -m -u 1000 user && \ | |
chown -R user:user /app | |
# Set environment variables for runtime | |
ENV PYTHONPATH=/app \ | |
PYTHONUNBUFFERED=1 \ | |
GRADIO_ALLOW_FLAGGING=never \ | |
GRADIO_NUM_PORTS=1 \ | |
GRADIO_SERVER_NAME=0.0.0.0 \ | |
GRADIO_THEME=huggingface \ | |
GRADIO_SHARE=False \ | |
SYSTEM=spaces \ | |
CUDA_DEVICE_ORDER=PCI_BUS_ID \ | |
CUDA_VISIBLE_DEVICES=0 | |
# Switch to user | |
USER user | |
WORKDIR /app | |
# Copy application file (assuming it's in the build context) | |
COPY --chown=user:user app.py /app/ | |
# Run the application | |
CMD ["python", "app.py"] |