File size: 1,023 Bytes
fabcfe8
2187ad4
fabcfe8
abbeb5a
 
 
 
fabcfe8
abbeb5a
 
fabcfe8
 
 
 
 
abbeb5a
fabcfe8
 
 
 
abbeb5a
fabcfe8
 
 
abbeb5a
fabcfe8
 
 
 
 
abbeb5a
 
fabcfe8
abbeb5a
fabcfe8
 
abbeb5a
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Base image with PyTorch 2.4.0 + CUDA 12.1
FROM pytorch/pytorch:2.4.0-cuda12.1-cudnn9-runtime

# Install system dependencies
RUN apt-get update && apt-get install -y wget git && rm -rf /var/lib/apt/lists/*

# Add non-root user
RUN useradd -m -u 1000 user

# Switch to non-root user
USER user
WORKDIR /app

# Environment variables
ENV PATH="/home/user/.local/bin:$PATH"
ENV TRANSFORMERS_CACHE=/home/user/.cache/huggingface
ENV TORCH_CUDA_ARCH_LIST="8.0+PTX"
ENV MODEL_DIR=/app/models/minicpmv

# Copy requirements and install Python dependencies
COPY requirements.txt .
RUN pip install --upgrade pip setuptools wheel
RUN pip install --no-cache-dir -r requirements.txt

# Download MiniCPM-V-4 model at build time
RUN python -c "\
from huggingface_hub import snapshot_download; \
snapshot_download('openbmb/MiniCPM-V-4', local_dir='/app/models/minicpmv', local_dir_use_symlinks=False) \
"

# Copy app code
COPY . .

# Expose port
EXPOSE 7860

# Start FastAPI
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]