Update Dockerfile
Browse files- Dockerfile +16 -15
Dockerfile
CHANGED
|
@@ -2,33 +2,32 @@
|
|
| 2 |
FROM python:3.10-slim-buster
|
| 3 |
|
| 4 |
# Set the working directory in the container
|
| 5 |
-
WORKDIR /app
|
| 6 |
|
| 7 |
-
# Install system dependencies needed for MLC LLM
|
|
|
|
| 8 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 9 |
git \
|
| 10 |
build-essential \
|
| 11 |
cmake \
|
| 12 |
-
|
| 13 |
-
ffmpeg \
|
| 14 |
-
libsm6 \
|
| 15 |
-
libxext6 \
|
| 16 |
-
rsync \
|
| 17 |
-
libgl1 \
|
| 18 |
-
&& rm -rf /var/lib/apt/lists/* \
|
| 19 |
-
&& git lfs install
|
| 20 |
|
| 21 |
# Copy the requirements file and install Python dependencies
|
| 22 |
COPY requirements.txt .
|
| 23 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
| 24 |
|
| 25 |
-
# Install torch specifically for CUDA if using GPU
|
|
|
|
|
|
|
|
|
|
| 26 |
RUN pip uninstall -y torch && pip install torch==2.1.0 --extra-index-url https://download.pytorch.org/whl/cu118
|
| 27 |
|
| 28 |
# Copy the Flask application files
|
| 29 |
COPY app.py .
|
| 30 |
|
| 31 |
-
# Copy the model artifacts
|
|
|
|
|
|
|
| 32 |
COPY model_artifacts ./model_artifacts
|
| 33 |
|
| 34 |
# Expose the port the app runs on
|
|
@@ -36,7 +35,9 @@ EXPOSE 5000
|
|
| 36 |
|
| 37 |
# Define environment variables for MLC LLM model paths
|
| 38 |
ENV MLC_MODEL_ARTIFACTS_DIR="./model_artifacts"
|
| 39 |
-
ENV MLC_MODEL_NAME="Llama-2-7b-chat-hf-q4f16_1"
|
| 40 |
|
| 41 |
# Command to run the Flask application
|
| 42 |
-
|
|
|
|
|
|
|
|
|
| 2 |
FROM python:3.10-slim-buster
|
| 3 |
|
| 4 |
# Set the working directory in the container
|
| 5 |
+
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Install system dependencies needed for MLC LLM (e.g., git, cmake for build tools if compiling on the fly)
|
| 8 |
+
# These are necessary for MLC LLM's build process if models are compiled within the container
|
| 9 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 10 |
git \
|
| 11 |
build-essential \
|
| 12 |
cmake \
|
| 13 |
+
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
# Copy the requirements file and install Python dependencies
|
| 16 |
COPY requirements.txt .
|
| 17 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 18 |
|
| 19 |
+
# Install torch specifically for CUDA if using GPU, otherwise use CPU
|
| 20 |
+
# For HuggingFace Spaces with GPU, CUDA 11.8 is a common and recommended version.
|
| 21 |
+
# Users might need to adjust 'cu118' to 'cpu' or a different CUDA version based on their target hardware.
|
| 22 |
+
# MLC-LLM might have its own torch dependency, ensure compatibility or remove this line if MLC-LLM handles it.
|
| 23 |
RUN pip uninstall -y torch && pip install torch==2.1.0 --extra-index-url https://download.pytorch.org/whl/cu118
|
| 24 |
|
| 25 |
# Copy the Flask application files
|
| 26 |
COPY app.py .
|
| 27 |
|
| 28 |
+
# Copy the model artifacts. This assumes model_artifacts exists and is populated.
|
| 29 |
+
# For large models, consider using git-lfs for HuggingFace Spaces or downloading at runtime
|
| 30 |
+
# if the model is too large for the Docker image or needs dynamic loading.
|
| 31 |
COPY model_artifacts ./model_artifacts
|
| 32 |
|
| 33 |
# Expose the port the app runs on
|
|
|
|
| 35 |
|
| 36 |
# Define environment variables for MLC LLM model paths
|
| 37 |
ENV MLC_MODEL_ARTIFACTS_DIR="./model_artifacts"
|
| 38 |
+
ENV MLC_MODEL_NAME="Llama-2-7b-chat-hf-q4f16_1" # Ensure this matches your downloaded model
|
| 39 |
|
| 40 |
# Command to run the Flask application
|
| 41 |
+
# Using Flask's built-in server for simplicity in development and small deployments.
|
| 42 |
+
# For production-grade deployments, consider a WSGI server like Gunicorn (e.g., gunicorn --bind 0.0.0.0:5000 app:app)
|
| 43 |
+
CMD ["python", "app.py"]
|