Spaces:
Sleeping
Sleeping
File size: 1,205 Bytes
cc844d3 6b07bd4 |
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 |
# Use an official Python runtime as a parent image
FROM python:3.9-slim
# Set the working directory
WORKDIR /app
# Install necessary system dependencies
RUN apt-get update && apt-get install -y gcc && rm -rf /var/lib/apt/lists/*
# Set the CC environment variable to ensure TorchInductor uses the correct compiler
ENV CC=gcc
# Copy the requirements file and install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Create cache and config directories with appropriate permissions
RUN mkdir -p /app/cache && chmod 777 /app/cache
RUN mkdir -p /app/config && chmod 777 /app/config
RUN mkdir -p /app/triton_cache && chmod 777 /app/triton_cache
RUN mkdir -p /app/torchinductor_cache && chmod 777 /app/torchinductor_cache
# Set environment variables for Hugging Face cache, config, Triton, and TorchInductor directories
ENV HF_HOME=/app/cache
ENV XDG_CONFIG_HOME=/app/config
ENV TRITON_CACHE_DIR=/app/triton_cache
ENV TORCHINDUCTOR_CACHE_DIR=/app/torchinductor_cache
# Copy the application code
COPY main.py .
# Expose the port FastAPI will run on
EXPOSE 7860
# Command to run the FastAPI app
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|