Update Dockerfile to pre-download model during build
Browse filesAdd RUN command to execute download_model.py during container build to pre-cache the Kimi-K2-Instruct model
- Dockerfile +25 -22
Dockerfile
CHANGED
|
@@ -5,32 +5,35 @@ WORKDIR /app
|
|
| 5 |
# Install system dependencies
|
| 6 |
RUN apt-get update && apt-get install -y \
|
| 7 |
git \
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
|
| 12 |
-
# Initialize git-lfs
|
| 13 |
-
RUN git lfs install
|
| 14 |
|
| 15 |
-
# Install Python packages
|
| 16 |
-
COPY requirements.txt .
|
| 17 |
-
RUN pip install --no-cache-dir --upgrade pip && \
|
| 18 |
-
|
| 19 |
|
| 20 |
-
# Copy application files
|
| 21 |
-
COPY . .
|
| 22 |
|
| 23 |
-
# Set up Hugging Face cache directory
|
| 24 |
-
ENV HF_HOME=/app/cache
|
| 25 |
-
ENV TRANSFORMERS_CACHE=/app/cache
|
| 26 |
-
ENV HF_HUB_CACHE=/app/cache
|
| 27 |
|
| 28 |
-
# Set environment variables for better performance
|
| 29 |
-
ENV PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:512
|
| 30 |
-
ENV CUDA_VISIBLE_DEVICES=0,1,2,3
|
| 31 |
|
| 32 |
-
#
|
| 33 |
-
|
| 34 |
|
| 35 |
-
#
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
# Install system dependencies
|
| 6 |
RUN apt-get update && apt-get install -y \
|
| 7 |
git \
|
| 8 |
+
git-lfs \
|
| 9 |
+
build-essential \
|
| 10 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
| 12 |
+
# Initialize git-lfs
|
| 13 |
+
RUN git lfs install
|
| 14 |
|
| 15 |
+
# Install Python packages
|
| 16 |
+
COPY requirements.txt .
|
| 17 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
| 18 |
+
pip install --no-cache-dir -r requirements.txt
|
| 19 |
|
| 20 |
+
# Copy application files
|
| 21 |
+
COPY . .
|
| 22 |
|
| 23 |
+
# Set up Hugging Face cache directory
|
| 24 |
+
ENV HF_HOME=/app/cache
|
| 25 |
+
ENV TRANSFORMERS_CACHE=/app/cache
|
| 26 |
+
ENV HF_HUB_CACHE=/app/cache
|
| 27 |
|
| 28 |
+
# Set environment variables for better performance
|
| 29 |
+
ENV PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:512
|
| 30 |
+
ENV CUDA_VISIBLE_DEVICES=0,1,2,3
|
| 31 |
|
| 32 |
+
# Pre-download model during build
|
| 33 |
+
RUN python download_model.py
|
| 34 |
|
| 35 |
+
# Expose port for the application
|
| 36 |
+
EXPOSE 7860
|
| 37 |
+
|
| 38 |
+
# Run the application
|
| 39 |
+
CMD ["python", "app.py"]
|