Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +22 -16
Dockerfile
CHANGED
|
@@ -10,27 +10,20 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 10 |
libgl1 \
|
| 11 |
libglib2.0-0 \
|
| 12 |
libgomp1 \
|
| 13 |
-
gcc \
|
| 14 |
-
g++ \
|
| 15 |
&& rm -rf /var/lib/apt/lists/*
|
| 16 |
|
| 17 |
WORKDIR /app
|
| 18 |
|
| 19 |
-
# 1) Torch CPU-only
|
| 20 |
RUN pip install --no-cache-dir \
|
| 21 |
torch==2.3.0+cpu \
|
| 22 |
torchvision==0.18.0+cpu \
|
| 23 |
--index-url https://download.pytorch.org/whl/cpu
|
| 24 |
|
| 25 |
-
# 2) mmengine
|
| 26 |
-
RUN pip install --no-cache-dir mmengine==0.10.4
|
| 27 |
|
| 28 |
-
# 3)
|
| 29 |
-
RUN pip install --no-cache-dir \
|
| 30 |
-
mmcv==2.1.0 \
|
| 31 |
-
-f https://download.openmmlab.com/mmcv/dist/cpu/torch2.3/index.html
|
| 32 |
-
|
| 33 |
-
# 4) Reste des dépendances
|
| 34 |
RUN pip install --no-cache-dir \
|
| 35 |
fastapi==0.111.0 \
|
| 36 |
"uvicorn[standard]==0.29.0" \
|
|
@@ -42,17 +35,30 @@ RUN pip install --no-cache-dir \
|
|
| 42 |
einops==0.8.0 \
|
| 43 |
huggingface_hub==0.23.0
|
| 44 |
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
-
# 5)
|
| 48 |
RUN python -c "\
|
|
|
|
| 49 |
import mmcv; import mmengine; import torch; \
|
| 50 |
-
print('mmcv:', mmcv.__version__, '| mmengine:', mmengine.__version__
|
| 51 |
-
|
| 52 |
-
model = torch.hub.load('
|
|
|
|
| 53 |
print('Poids en cache OK.'); \
|
| 54 |
del model"
|
| 55 |
|
|
|
|
|
|
|
| 56 |
EXPOSE 7860
|
| 57 |
|
| 58 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 10 |
libgl1 \
|
| 11 |
libglib2.0-0 \
|
| 12 |
libgomp1 \
|
|
|
|
|
|
|
| 13 |
&& rm -rf /var/lib/apt/lists/*
|
| 14 |
|
| 15 |
WORKDIR /app
|
| 16 |
|
| 17 |
+
# 1) Torch CPU-only
|
| 18 |
RUN pip install --no-cache-dir \
|
| 19 |
torch==2.3.0+cpu \
|
| 20 |
torchvision==0.18.0+cpu \
|
| 21 |
--index-url https://download.pytorch.org/whl/cpu
|
| 22 |
|
| 23 |
+
# 2) mmengine + mmcv-lite (pur Python, pas de compilation C++/CUDA)
|
| 24 |
+
RUN pip install --no-cache-dir mmengine==0.10.4 mmcv-lite==2.1.0
|
| 25 |
|
| 26 |
+
# 3) Reste des dépendances
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
RUN pip install --no-cache-dir \
|
| 28 |
fastapi==0.111.0 \
|
| 29 |
"uvicorn[standard]==0.29.0" \
|
|
|
|
| 35 |
einops==0.8.0 \
|
| 36 |
huggingface_hub==0.23.0
|
| 37 |
|
| 38 |
+
# 4) Cloner Metric3D et patcher l'import mmcv.utils → mmengine
|
| 39 |
+
# (mono/utils/comm.py importe encore l'ancien mmcv.utils)
|
| 40 |
+
RUN git clone https://github.com/YvanYin/Metric3D.git /metric3d && \
|
| 41 |
+
# Remplacer "from mmcv.utils import collect_env as collect_base_env"
|
| 42 |
+
# par un import neutre qui ne plante pas
|
| 43 |
+
sed -i 's/from mmcv.utils import collect_env as collect_base_env/from mmengine.utils.dl_utils import collect_env as collect_base_env/g' \
|
| 44 |
+
/metric3d/mono/utils/comm.py && \
|
| 45 |
+
# Forcer torch.hub à utiliser le repo local déjà cloné
|
| 46 |
+
mkdir -p /root/.cache/torch/hub && \
|
| 47 |
+
cp -r /metric3d /root/.cache/torch/hub/yvanyin_metric3d_main
|
| 48 |
|
| 49 |
+
# 5) Pré-télécharger les poids (le repo est déjà en cache local)
|
| 50 |
RUN python -c "\
|
| 51 |
+
import sys; sys.path.insert(0, '/metric3d'); \
|
| 52 |
import mmcv; import mmengine; import torch; \
|
| 53 |
+
print('mmcv:', mmcv.__version__, '| mmengine:', mmengine.__version__); \
|
| 54 |
+
torch.hub.DEFAULT_CACHE_DIR = '/root/.cache/torch/hub'; \
|
| 55 |
+
model = torch.hub.load('/root/.cache/torch/hub/yvanyin_metric3d_main', \
|
| 56 |
+
'metric3d_vit_large', pretrain=True, source='local', trust_repo=True); \
|
| 57 |
print('Poids en cache OK.'); \
|
| 58 |
del model"
|
| 59 |
|
| 60 |
+
COPY app.py .
|
| 61 |
+
|
| 62 |
EXPOSE 7860
|
| 63 |
|
| 64 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|