Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +14 -12
Dockerfile
CHANGED
|
@@ -1,36 +1,38 @@
|
|
| 1 |
# Base image with PyTorch 2.4.0 + CUDA 12.1
|
| 2 |
FROM pytorch/pytorch:2.4.0-cuda12.1-cudnn9-runtime
|
| 3 |
|
| 4 |
-
#
|
|
|
|
|
|
|
|
|
|
| 5 |
RUN useradd -m -u 1000 user
|
|
|
|
|
|
|
| 6 |
USER user
|
| 7 |
WORKDIR /app
|
| 8 |
|
| 9 |
# Environment variables
|
| 10 |
ENV PATH="/home/user/.local/bin:$PATH"
|
| 11 |
-
ENV TRANSFORMERS_CACHE=/
|
| 12 |
ENV TORCH_CUDA_ARCH_LIST="8.0+PTX"
|
| 13 |
ENV MODEL_DIR=/app/models/minicpmv
|
| 14 |
|
| 15 |
-
# Install system dependencies
|
| 16 |
-
RUN apt-get update && apt-get install -y wget git && rm -rf /var/lib/apt/lists/*
|
| 17 |
-
|
| 18 |
# Copy requirements and install Python dependencies
|
| 19 |
-
COPY
|
| 20 |
RUN pip install --upgrade pip setuptools wheel
|
| 21 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 22 |
|
| 23 |
-
#
|
| 24 |
RUN python -c "\
|
| 25 |
from huggingface_hub import snapshot_download; \
|
| 26 |
snapshot_download('openbmb/MiniCPM-V-4', local_dir='/app/models/minicpmv', local_dir_use_symlinks=False) \
|
| 27 |
"
|
| 28 |
|
| 29 |
-
# Copy
|
| 30 |
-
COPY
|
| 31 |
|
| 32 |
-
# Expose
|
| 33 |
EXPOSE 7860
|
| 34 |
|
| 35 |
-
# Start
|
| 36 |
-
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
# Base image with PyTorch 2.4.0 + CUDA 12.1
|
| 2 |
FROM pytorch/pytorch:2.4.0-cuda12.1-cudnn9-runtime
|
| 3 |
|
| 4 |
+
# Install system dependencies
|
| 5 |
+
RUN apt-get update && apt-get install -y wget git && rm -rf /var/lib/apt/lists/*
|
| 6 |
+
|
| 7 |
+
# Add non-root user
|
| 8 |
RUN useradd -m -u 1000 user
|
| 9 |
+
|
| 10 |
+
# Switch to non-root user
|
| 11 |
USER user
|
| 12 |
WORKDIR /app
|
| 13 |
|
| 14 |
# Environment variables
|
| 15 |
ENV PATH="/home/user/.local/bin:$PATH"
|
| 16 |
+
ENV TRANSFORMERS_CACHE=/home/user/.cache/huggingface
|
| 17 |
ENV TORCH_CUDA_ARCH_LIST="8.0+PTX"
|
| 18 |
ENV MODEL_DIR=/app/models/minicpmv
|
| 19 |
|
|
|
|
|
|
|
|
|
|
| 20 |
# Copy requirements and install Python dependencies
|
| 21 |
+
COPY requirements.txt .
|
| 22 |
RUN pip install --upgrade pip setuptools wheel
|
| 23 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 24 |
|
| 25 |
+
# Download MiniCPM-V-4 model at build time
|
| 26 |
RUN python -c "\
|
| 27 |
from huggingface_hub import snapshot_download; \
|
| 28 |
snapshot_download('openbmb/MiniCPM-V-4', local_dir='/app/models/minicpmv', local_dir_use_symlinks=False) \
|
| 29 |
"
|
| 30 |
|
| 31 |
+
# Copy app code
|
| 32 |
+
COPY . .
|
| 33 |
|
| 34 |
+
# Expose port
|
| 35 |
EXPOSE 7860
|
| 36 |
|
| 37 |
+
# Start FastAPI
|
| 38 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|