Spaces:
Paused
Paused
Upload folder using huggingface_hub
Browse files- Dockerfile +40 -12
- requirements.txt +27 -0
Dockerfile
CHANGED
|
@@ -1,45 +1,73 @@
|
|
| 1 |
-
#
|
| 2 |
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04
|
| 3 |
|
| 4 |
-
#
|
| 5 |
ENV DEBIAN_FRONTEND=noninteractive \
|
| 6 |
PYTHONUNBUFFERED=1 \
|
| 7 |
GRADIO_SERVER_NAME=0.0.0.0 \
|
| 8 |
GRADIO_SERVER_PORT=7860 \
|
| 9 |
-
CUDA_HOME=/usr/local/cuda
|
|
|
|
| 10 |
|
| 11 |
-
# Install
|
| 12 |
RUN apt-get update && apt-get install -y \
|
| 13 |
python3.10 \
|
| 14 |
python3-pip \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
&& rm -rf /var/lib/apt/lists/* \
|
| 16 |
&& ln -s /usr/bin/python3.10 /usr/bin/python
|
| 17 |
|
| 18 |
-
#
|
| 19 |
RUN useradd -m -u 1000 user
|
| 20 |
|
| 21 |
# Switch to user
|
| 22 |
USER user
|
| 23 |
|
| 24 |
-
# Set
|
| 25 |
ENV HOME=/home/user \
|
| 26 |
PATH=/home/user/.local/bin:$PATH
|
| 27 |
|
| 28 |
# Set working directory
|
| 29 |
WORKDIR $HOME/app
|
| 30 |
|
| 31 |
-
# Copy requirements
|
| 32 |
COPY --chown=user requirements.txt .
|
| 33 |
|
| 34 |
-
# Install Python
|
| 35 |
-
RUN pip install --no-cache-dir --upgrade pip && \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
pip install --no-cache-dir -r requirements.txt
|
| 37 |
|
| 38 |
-
# Copy application
|
| 39 |
COPY --chown=user app.py .
|
| 40 |
|
| 41 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
EXPOSE 7860
|
| 43 |
|
| 44 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
CMD ["python", "app.py"]
|
|
|
|
| 1 |
+
# Production Docker image with all AI models and dependencies
|
| 2 |
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04
|
| 3 |
|
| 4 |
+
# Prevent interactive prompts
|
| 5 |
ENV DEBIAN_FRONTEND=noninteractive \
|
| 6 |
PYTHONUNBUFFERED=1 \
|
| 7 |
GRADIO_SERVER_NAME=0.0.0.0 \
|
| 8 |
GRADIO_SERVER_PORT=7860 \
|
| 9 |
+
CUDA_HOME=/usr/local/cuda \
|
| 10 |
+
HF_HOME=/home/user/.cache/huggingface
|
| 11 |
|
| 12 |
+
# Install system dependencies
|
| 13 |
RUN apt-get update && apt-get install -y \
|
| 14 |
python3.10 \
|
| 15 |
python3-pip \
|
| 16 |
+
python3-dev \
|
| 17 |
+
build-essential \
|
| 18 |
+
git \
|
| 19 |
+
curl \
|
| 20 |
+
wget \
|
| 21 |
+
ffmpeg \
|
| 22 |
+
libsm6 \
|
| 23 |
+
libxext6 \
|
| 24 |
+
libxrender-dev \
|
| 25 |
+
libgomp1 \
|
| 26 |
&& rm -rf /var/lib/apt/lists/* \
|
| 27 |
&& ln -s /usr/bin/python3.10 /usr/bin/python
|
| 28 |
|
| 29 |
+
# Create user with ID 1000
|
| 30 |
RUN useradd -m -u 1000 user
|
| 31 |
|
| 32 |
# Switch to user
|
| 33 |
USER user
|
| 34 |
|
| 35 |
+
# Set paths
|
| 36 |
ENV HOME=/home/user \
|
| 37 |
PATH=/home/user/.local/bin:$PATH
|
| 38 |
|
| 39 |
# Set working directory
|
| 40 |
WORKDIR $HOME/app
|
| 41 |
|
| 42 |
+
# Copy requirements first (for Docker layer caching)
|
| 43 |
COPY --chown=user requirements.txt .
|
| 44 |
|
| 45 |
+
# Install all Python dependencies
|
| 46 |
+
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
|
| 47 |
+
pip install --no-cache-dir gradio && \
|
| 48 |
+
pip install --no-cache-dir transformers accelerate diffusers && \
|
| 49 |
+
pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 && \
|
| 50 |
+
pip install --no-cache-dir opencv-python-headless pillow numpy scipy && \
|
| 51 |
+
pip install --no-cache-dir huggingface_hub hf-transfer && \
|
| 52 |
+
pip install --no-cache-dir sentencepiece protobuf && \
|
| 53 |
pip install --no-cache-dir -r requirements.txt
|
| 54 |
|
| 55 |
+
# Copy the complete application
|
| 56 |
COPY --chown=user app.py .
|
| 57 |
|
| 58 |
+
# Create necessary directories
|
| 59 |
+
RUN mkdir -p $HOME/app/data $HOME/.cache/huggingface
|
| 60 |
+
|
| 61 |
+
# Pre-download critical models (optional - uncomment if needed)
|
| 62 |
+
# RUN python -c "from huggingface_hub import snapshot_download; \
|
| 63 |
+
# snapshot_download('Qwen/Qwen2.5-7B-Instruct', cache_dir='$HF_HOME')"
|
| 64 |
+
|
| 65 |
+
# Expose port
|
| 66 |
EXPOSE 7860
|
| 67 |
|
| 68 |
+
# Health check
|
| 69 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
|
| 70 |
+
CMD curl -f http://localhost:7860/ || exit 1
|
| 71 |
+
|
| 72 |
+
# Launch Gradio app
|
| 73 |
CMD ["python", "app.py"]
|
requirements.txt
CHANGED
|
@@ -1 +1,28 @@
|
|
|
|
|
| 1 |
gradio>=4.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Core Gradio
|
| 2 |
gradio>=4.0
|
| 3 |
+
|
| 4 |
+
# AI/ML Frameworks
|
| 5 |
+
transformers>=4.30.0
|
| 6 |
+
accelerate
|
| 7 |
+
diffusers
|
| 8 |
+
sentencepiece
|
| 9 |
+
protobuf
|
| 10 |
+
|
| 11 |
+
# Image Processing
|
| 12 |
+
opencv-python-headless
|
| 13 |
+
pillow
|
| 14 |
+
imageio
|
| 15 |
+
|
| 16 |
+
# Audio Processing
|
| 17 |
+
librosa
|
| 18 |
+
soundfile
|
| 19 |
+
|
| 20 |
+
# Data Science
|
| 21 |
+
numpy
|
| 22 |
+
pandas
|
| 23 |
+
scipy
|
| 24 |
+
|
| 25 |
+
# Utilities
|
| 26 |
+
huggingface_hub
|
| 27 |
+
requests
|
| 28 |
+
aiohttp
|