File size: 1,805 Bytes
491c535
 
 
 
07a620f
530c4d7
 
 
 
 
 
07a620f
 
 
530c4d7
f5641f5
530c4d7
491c535
07a620f
491c535
 
 
 
530c4d7
491c535
530c4d7
07a620f
530c4d7
07a620f
 
491c535
530c4d7
 
 
 
07a620f
 
 
 
530c4d7
 
 
 
 
 
 
 
34c89e1
fe8b66b
34c89e1
530c4d7
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
FROM python:3.11-slim

ENV PIP_NO_CACHE_DIR=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    APP_CACHE=/tmp/appcache \
    XDG_CACHE_HOME=/tmp/appcache \
    HF_HOME=/tmp/appcache/hf \
    HUGGINGFACE_HUB_CACHE=/tmp/appcache/hf \
    TORCH_HOME=/tmp/appcache/torch \
    OPENCLIP_CACHE_DIR=/tmp/appcache/open_clip \
    HF_HUB_ENABLE_HF_TRANSFER=0 \
    OMP_NUM_THREADS=2 \
    MKL_NUM_THREADS=2 \
    NUM_THREADS=2

# deps del sistema: OpenMP y build tools
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential git libgomp1 && \
    rm -rf /var/lib/apt/lists/*

WORKDIR /app

# deps de proyecto (ligeras)
COPY requirements.txt ./
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt

# PyTorch CPU wheels oficiales
RUN pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu \
    torch torchvision

# (opcional) asegurar que open_clip este instalado (si no viene por reqs)
# RUN pip install --no-cache-dir open_clip_torch

# copiar codigo y embeddings
COPY server1.py ./server1.py
COPY text_embeddings_modelos_bigg.pt ./text_embeddings_modelos_bigg.pt
COPY text_embeddings_bigg.pt ./text_embeddings_bigg.pt

# (opcional) precarga ligera para evitar cold-start de dependencias
# No hace forward pesado ni cambia precision
# RUN python - <<'PY'\n\
# import open_clip\n\
# open_clip.create_model_and_transforms('hf-hub:timm/PE-Core-bigG-14-448', pretrained=None)\n\
# print('open_clip model meta loaded')\n\
# PY

ENV PORT=7860
EXPOSE 7860

# uvloop + httptools (vienen con uvicorn[standard]); 1 worker evita duplicar el modelo
CMD ["uvicorn", "server1:app", "--host", "0.0.0.0", "--port", "7860", "--loop", "uvloop", "--http", "httptools", "--workers", "1", "--no-server-header", "--timeout-keep-alive", "5"]