infinitetalk / Dockerfile
ShalomKing's picture
Fix torchvision NMS registration on ZeroGPU
4eab2ed verified
raw
history blame
2.24 kB
FROM nvidia/cuda:12.1.0-devel-ubuntu22.04
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive \
PYTHONUNBUFFERED=1 \
PYTHON_VERSION=3.10 \
TORCHVISION_DISABLE_META_REGISTRATIONS=1
# Install system dependencies
RUN apt-get update && apt-get install -y \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-dev \
python3-pip \
git \
git-lfs \
ffmpeg \
build-essential \
libsndfile1 \
ninja-build \
wget \
&& rm -rf /var/lib/apt/lists/* \
&& git lfs install
# Set Python 3.10 as default
RUN update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 1 && \
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 1
# Upgrade pip
RUN python -m pip install --no-cache-dir --upgrade pip setuptools wheel
# Install PyTorch 2.5.1+ FIRST (required for xfuser's torch.distributed.tensor.experimental)
RUN pip install --no-cache-dir \
torch==2.5.1 \
torchvision==0.20.1 \
torchaudio==2.5.1 \
--index-url https://download.pytorch.org/whl/cu121
# Try to install flash-attn, but don't fail if it doesn't work
RUN pip install --no-cache-dir flash-attn==2.7.4.post1 --no-build-isolation || \
echo "Warning: flash-attn installation failed, continuing without it (will use slower attention)"
# Set working directory
WORKDIR /app
# Copy requirements.txt first for better caching
COPY requirements.txt .
# Install remaining requirements (skip torch, torchvision, torchaudio, flash-attn as they're already installed)
RUN pip install --no-cache-dir -r requirements.txt || \
(echo "Some packages failed to install" && pip install --no-cache-dir -r requirements.txt --ignore-installed)
# Copy application files
COPY . .
# Create user directory and set permissions
RUN useradd -m -u 1000 user && \
chown -R user:user /app && \
mkdir -p /home/user/.cache /home/user/.local && \
chown -R user:user /home/user
# Switch to non-root user
USER user
# Set environment for HuggingFace
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
PYTHONPATH=/app \
HF_HOME=/home/user/.cache/huggingface
# Expose port for Gradio
EXPOSE 7860
# Run the application
CMD ["python", "app.py"]