Commit ·
faf20d1
1
Parent(s): 15f9d61
update dockerfiles & requirements - HF
Browse files- Dockerfile +10 -8
- requirements.txt +1 -1
Dockerfile
CHANGED
|
@@ -6,12 +6,9 @@ WORKDIR /app
|
|
| 6 |
|
| 7 |
# 3. Install minimal system dependencies
|
| 8 |
# - libgl1/libglib2.0-0: OpenCV needs these
|
| 9 |
-
# - build-essential/python3-dev: llama-cpp-python builds from source
|
| 10 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 11 |
libgl1 \
|
| 12 |
libglib2.0-0 \
|
| 13 |
-
build-essential \
|
| 14 |
-
python3-dev \
|
| 15 |
&& rm -rf /var/lib/apt/lists/*
|
| 16 |
|
| 17 |
# 4. Install PyTorch CPU-only FIRST (saves ~1.5GB vs full CUDA torch)
|
|
@@ -19,20 +16,25 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 19 |
RUN pip install --no-cache-dir \
|
| 20 |
torch --index-url https://download.pytorch.org/whl/cpu
|
| 21 |
|
| 22 |
-
# 5. Install
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
COPY requirements.txt .
|
| 24 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 25 |
|
| 26 |
-
#
|
| 27 |
COPY . .
|
| 28 |
|
| 29 |
-
#
|
| 30 |
RUN python download_models.py
|
| 31 |
|
| 32 |
-
#
|
| 33 |
ENV PYTHONPATH=/app
|
| 34 |
ENV USE_EMBEDDED_LLM=True
|
| 35 |
EXPOSE 7860
|
| 36 |
|
| 37 |
-
#
|
| 38 |
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 6 |
|
| 7 |
# 3. Install minimal system dependencies
|
| 8 |
# - libgl1/libglib2.0-0: OpenCV needs these
|
|
|
|
| 9 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 10 |
libgl1 \
|
| 11 |
libglib2.0-0 \
|
|
|
|
|
|
|
| 12 |
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
|
| 14 |
# 4. Install PyTorch CPU-only FIRST (saves ~1.5GB vs full CUDA torch)
|
|
|
|
| 16 |
RUN pip install --no-cache-dir \
|
| 17 |
torch --index-url https://download.pytorch.org/whl/cpu
|
| 18 |
|
| 19 |
+
# 5. Install llama-cpp-python from pre-built CPU wheels (avoids 30+ min C++ compile)
|
| 20 |
+
RUN pip install --no-cache-dir \
|
| 21 |
+
llama-cpp-python \
|
| 22 |
+
--extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu
|
| 23 |
+
|
| 24 |
+
# 6. Install remaining Python dependencies
|
| 25 |
COPY requirements.txt .
|
| 26 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 27 |
|
| 28 |
+
# 7. Copy your code
|
| 29 |
COPY . .
|
| 30 |
|
| 31 |
+
# 8. Download all ML models (Face, Text, LLaMA 3 GGUF) during build
|
| 32 |
RUN python download_models.py
|
| 33 |
|
| 34 |
+
# 9. Environment & Port settings (7860 is HF Spaces standard)
|
| 35 |
ENV PYTHONPATH=/app
|
| 36 |
ENV USE_EMBEDDED_LLM=True
|
| 37 |
EXPOSE 7860
|
| 38 |
|
| 39 |
+
# 10. Run the app with Uvicorn
|
| 40 |
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
requirements.txt
CHANGED
|
@@ -21,9 +21,9 @@ pillow
|
|
| 21 |
gdown
|
| 22 |
|
| 23 |
# --- NLP (PyTorch CPU-only via --index-url, see Dockerfile) ---
|
|
|
|
| 24 |
transformers>=4.40.0
|
| 25 |
sentencepiece==0.1.99
|
| 26 |
-
llama-cpp-python>=0.2.77
|
| 27 |
huggingface-hub>=0.23.0
|
| 28 |
|
| 29 |
# --- Utilities ---
|
|
|
|
| 21 |
gdown
|
| 22 |
|
| 23 |
# --- NLP (PyTorch CPU-only via --index-url, see Dockerfile) ---
|
| 24 |
+
# llama-cpp-python is installed separately in Dockerfile from pre-built CPU wheels
|
| 25 |
transformers>=4.40.0
|
| 26 |
sentencepiece==0.1.99
|
|
|
|
| 27 |
huggingface-hub>=0.23.0
|
| 28 |
|
| 29 |
# --- Utilities ---
|