Spaces:
Sleeping
Sleeping
File size: 1,064 Bytes
99953a6 fdd52fa d2efd72 fdd52fa 8edf245 fdd52fa d2efd72 fdd52fa d2efd72 fdd52fa afe3bd7 |
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 |
FROM python:3.12
WORKDIR /app
# Tạo thư mục cache cho huggingface, cấp quyền ghi
RUN mkdir -p /cache && chmod 777 /cache
# Cài g++ để tránh lỗi transformers build lại tokenizer
RUN apt-get update && apt-get install -y g++ && apt-get upgrade -y && apt-get clean && rm -rf /var/lib/apt/lists/*
# Set biến môi trường để huggingface cache model vào /cache
ENV TRANSFORMERS_CACHE=/cache
ENV HF_HOME=/cache
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
# Tải sẵn model lúc build để tránh lỗi runtime permission
RUN python -c "from transformers import M2M100Tokenizer, M2M100ForConditionalGeneration; \
M2M100Tokenizer.from_pretrained('longvnhue1/facebook-m2m100_418M-fine_tuning'); \
M2M100ForConditionalGeneration.from_pretrained('longvnhue1/facebook-m2m100_418M-fine_tuning')"
# Mặc định FastAPI chạy bằng Uvicorn
# CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "2"]
|