FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 | |
# Install basic dependencies | |
RUN apt-get update && apt-get install -y \ | |
wget \ | |
git \ | |
python3 \ | |
python3-pip \ | |
ffmpeg \ | |
libsm6 \ | |
libxext6 \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Create non-root user | |
RUN useradd -m -s /bin/bash huggingface | |
WORKDIR /home/huggingface | |
# Set up git config | |
RUN git config --global user.email "[email protected]" && \ | |
git config --global user.name "jmanhype" | |
# Copy application code | |
COPY . /home/huggingface/app/ | |
WORKDIR /home/huggingface/app | |
# Install Python dependencies | |
RUN pip3 install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 | |
RUN pip3 install --no-cache-dir -r requirements.txt | |
RUN pip3 install --no-cache-dir gradio spaces | |
# Install additional dependencies for controlnet_aux | |
RUN pip3 install --no-cache-dir openmim && \ | |
mim install mmcv>=2.0.1 && \ | |
mim install mmdet>=3.1.0 && \ | |
mim install mmpose>=1.1.0 | |
# Set Python path | |
ENV PYTHONPATH=/home/huggingface/app:/home/huggingface/app/MMCM:/home/huggingface/app/diffusers/src:/home/huggingface/app/controlnet_aux/src | |
# Set ownership | |
RUN chown -R huggingface:huggingface /home/huggingface | |
# Switch to non-root user | |
USER huggingface | |
# Expose port | |
EXPOSE 7860 | |
# Run the app | |
CMD ["python3", "scripts/gradio/app_gradio_space.py"] |