FROM python:3.9 WORKDIR /code COPY ./requirements.txt /code/requirements.txt RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt RUN apt-get update && apt-get install ffmpeg libsm6 libxext6 -y # Create the cache directory and set permissions RUN mkdir -p /code/transformers_cache && chmod -R 777 /code/transformers_cache # Set the TRANSFORMERS_CACHE and HF_HOME environment variables ENV TRANSFORMERS_CACHE=/code/transformers_cache ENV HF_HOME=/code/transformers_cache # Set PyTorch CUDA memory management variable ENV PYTORCH_CUDA_ALLOC_CONF=garbage_collection_threshold:0.6,max_split_size_mb:128 COPY . . CMD ["gunicorn", "-b", "0.0.0.0:7860", "main:app", "--timeout", "600"]