Spaces:
Build error
Build error
Update Dockerfile
Browse files5 unmodified lines6789101112131415161718192021222324252627282930313233343536373839404142434445465 unmodified linesXDG_CACHE_HOME=/cache \OMP_NUM_THREADS=1RUN pip install --no-cache-dir fastapi uvicorn[standard] sentence-transformersWORKDIR /appRUN mkdir -p /cache && chmod -R 777 /cacheRUN echo 'from fastapi import FastAPI\n\from pydantic import BaseModel\n\from typing import List\n\from sentence_transformers import SentenceTransformer\n\import torch\n\\n\app = FastAPI(title="gte-large-embed")\n\\n\device = "cuda" if torch.cuda.is_available() else "cpu"\n\model = SentenceTransformer("thenlper/gte-large", device=device)\n\\n\class EmbedIn(BaseModel):\n\texts: List[str]\n\normalize: bool = True\n\batch_size: int = 32\n\\n\@app.get("/health")\n\def health():\n\return {"ok": True, "device": device}\n\\n\@app.post("/embed")\n\def embed(inp: EmbedIn):\n\vecs = model.encode(\n\inp.texts,\n\normalize_embeddings=inp.normalize,\n\batch_size=inp.batch_size,\n\convert_to_numpy=True,\n\show_progress_bar=False,\n\)\n\return {"embeddings": vecs.tolist(), "dim": int(vecs.shape[1])}\n' > app.pyEXPOSE 7860CMD ["uvicorn","app:app","--host","0.0.0.0","--port","7860","--workers","1"]5 unmodified lines6789101112131415161718192021222324252627282930313233343536373839405 unmodified linesXDG_CACHE_HOME=/cache \OMP_NUM_THREADS=1RUN pip install --no-cache-dir "torch==2.3.1+cpu" --index-url https://download.pytorch.org/whl/cpu \&& pip install --no-cache-dir fastapi uvicorn[standard] sentence-transformersWORKDIR /appRUN mkdir -p /cache && chmod -R 777 /cache# write the appRUN echo 'from fastapi import FastAPI\n\from pydantic import BaseModel\n\from typing import List\n\from sentence_transformers import SentenceTransformer\n\import torch\n\app = FastAPI(title=\"gte-large-embed\")\n\device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n\model = SentenceTransformer(\"thenlper/gte-large\", device=device)\n\class EmbedIn(BaseModel):\n\texts: List[str]\n\normalize: bool = True\n\batch_size: int = 32\n\@app.get(\"/health\")\n\def health():\n\return {\"ok\": True, \"device\": device}\n\@app.post(\"/embed\")\n\def embed(inp: EmbedIn):\n\vecs = model.encode(inp.texts, normalize_embeddings=inp.normalize, batch_size=inp.batch_size, convert_to_numpy=True, show_progress_bar=False)\n\return {\"embeddings\": vecs.tolist(), \"dim\": int(vecs.shape[1])}\n' > app.py# pre-download at build time to avoid /.cache permission issuesRUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('thenlper/gte-large').save('/cache/preload')"EXPOSE 7860CMD ["uvicorn","app:app","--host","0.0.0.0","--port","7860","--workers","1"]
Dockerfile+14-20