Clean rebuild: all features fixed
Browse files- Dockerfile +13 -8
Dockerfile
CHANGED
|
@@ -24,11 +24,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 24 |
|
| 25 |
WORKDIR /app
|
| 26 |
|
| 27 |
-
# ββ Pin numpy FIRST β must be before torch and all other packages ββ
|
| 28 |
-
# numpy==1.26.4 required by torch 2.1.0, transformers 4.35.2, chromadb 0.5.3
|
| 29 |
-
# HF environment has numpy 2.x which breaks these; pin here to lock it early
|
| 30 |
-
RUN pip install --no-cache-dir "numpy==1.26.4"
|
| 31 |
-
|
| 32 |
# ββ Install PyTorch CPU ββββββββββββββββββββββββββββββββββββββ
|
| 33 |
RUN pip install --no-cache-dir \
|
| 34 |
torch==2.1.0+cpu \
|
|
@@ -45,9 +40,6 @@ COPY cv_module/requirements.txt /tmp/cv-requirements.txt
|
|
| 45 |
RUN sed -i '/^torch==/d; /^torchvision==/d; /^numpy==/d' /tmp/cv-requirements.txt && \
|
| 46 |
pip install --no-cache-dir -r /tmp/cv-requirements.txt
|
| 47 |
|
| 48 |
-
# ββ Re-pin numpy after CV deps (open-clip-torch upgrades it) ββββ
|
| 49 |
-
RUN pip install --no-cache-dir --force-reinstall "numpy==1.26.4"
|
| 50 |
-
|
| 51 |
# ββ YOLO ONNX export at build time ββββββββββββββββββββββββββ
|
| 52 |
COPY scripts/export_yolo_onnx.py /tmp/export_yolo_onnx.py
|
| 53 |
RUN mkdir -p /app/cv/model_cache && \
|
|
@@ -56,6 +48,19 @@ RUN mkdir -p /app/cv/model_cache && \
|
|
| 56 |
pip uninstall -y ultralytics && \
|
| 57 |
rm -f yolov8n.pt yolov8n.onnx /tmp/export_yolo_onnx.py
|
| 58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
# ββ Patch chromadb DefaultEmbeddingFunction ββββββββββββββββββ
|
| 60 |
COPY scripts/patch_libs.py /tmp/patch_libs.py
|
| 61 |
RUN python /tmp/patch_libs.py || echo "patches finished with warnings"
|
|
|
|
| 24 |
|
| 25 |
WORKDIR /app
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
# ββ Install PyTorch CPU ββββββββββββββββββββββββββββββββββββββ
|
| 28 |
RUN pip install --no-cache-dir \
|
| 29 |
torch==2.1.0+cpu \
|
|
|
|
| 40 |
RUN sed -i '/^torch==/d; /^torchvision==/d; /^numpy==/d' /tmp/cv-requirements.txt && \
|
| 41 |
pip install --no-cache-dir -r /tmp/cv-requirements.txt
|
| 42 |
|
|
|
|
|
|
|
|
|
|
| 43 |
# ββ YOLO ONNX export at build time ββββββββββββββββββββββββββ
|
| 44 |
COPY scripts/export_yolo_onnx.py /tmp/export_yolo_onnx.py
|
| 45 |
RUN mkdir -p /app/cv/model_cache && \
|
|
|
|
| 48 |
pip uninstall -y ultralytics && \
|
| 49 |
rm -f yolov8n.pt yolov8n.onnx /tmp/export_yolo_onnx.py
|
| 50 |
|
| 51 |
+
# ββ Patch chromadb for numpy 2.x compatibility βββββββββββββββ
|
| 52 |
+
# chromadb 0.5.3 uses np.float_, np.int_, np.uint which were removed in numpy 2.0
|
| 53 |
+
# Patch the source directly since we can't pin numpy (other deps force numpy 2.x)
|
| 54 |
+
RUN python -c "
|
| 55 |
+
import pathlib, re
|
| 56 |
+
p = pathlib.Path('/usr/local/lib/python3.10/site-packages/chromadb/api/types.py')
|
| 57 |
+
if p.exists():
|
| 58 |
+
t = p.read_text()
|
| 59 |
+
t = t.replace('np.uint, np.int_, np.float_', 'np.unsignedinteger, np.signedinteger, np.float64')
|
| 60 |
+
p.write_text(t)
|
| 61 |
+
print('chromadb types.py patched for numpy 2.x')
|
| 62 |
+
"
|
| 63 |
+
|
| 64 |
# ββ Patch chromadb DefaultEmbeddingFunction ββββββββββββββββββ
|
| 65 |
COPY scripts/patch_libs.py /tmp/patch_libs.py
|
| 66 |
RUN python /tmp/patch_libs.py || echo "patches finished with warnings"
|