Spaces:
yanng404
/
Sleeping

File size: 1,665 Bytes
d526a86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e3668ba
d526a86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Inference backend for the hosted Laya API (platform/api-platform), as a
# Hugging Face Docker Space on CPU Upgrade hardware (8 vCPU, 32 GB).
# Runs upstream `laya-serve` (Jev-compatible POST /v1/systemone and
# /v1/systemone/batch). The same image runs on T4 hardware: set the Space
# variable LAYA_DEVICE=cuda after switching.
FROM python:3.11-slim

RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH \
    HF_HOME=/home/user/.cache/huggingface \
    USE_TF=0 \
    PIP_NO_CACHE_DIR=1
WORKDIR /home/user/app

# CPU-only PyTorch first, so laya does not pull the large CUDA build.
# For T4 hardware, drop the --index-url so the CUDA build is installed.
# 0.3.22+ is needed for /v1/systemone/batch; 0.3.24 fixes its usage totals.
RUN pip install --user --index-url https://download.pytorch.org/whl/cpu torch \
 && pip install --user "laya[serve]==0.4.22"

# Bake all three checkpoints (~2.3 GB) into the image, so a restart serves
# immediately instead of downloading first. The API exposes all three.
RUN python -c "import laya; \
laya.load('convaiinnovations/laya'); \
laya.load('convaiinnovations/laya', subfolder='multilingual'); \
laya.load('convaiinnovations/laya', subfolder='typed-decisions')"

# LAYA_THREADS: torch threads per request. Start at 4 (the physical cores
# behind 8 vCPUs) and compare with 8 using platform/api-platform/scripts/
# bench-upstream.mjs; override it as a Space variable without rebuilding.
ENV LAYA_HOST=0.0.0.0 \
    LAYA_PORT=7860 \
    LAYA_DEVICE=cpu \
    LAYA_PRELOAD=1 \
    LAYA_MODELS=english,multilingual,typed-decisions \
    LAYA_THREADS=4

EXPOSE 7860
CMD ["laya-serve"]