Spaces:
Sleeping
Sleeping
FROM nvidia/cuda:12.2.0-runtime-ubuntu20.04 | |
ENV DEBIAN_FRONTEND=noninteractive | |
# Install basic system dependencies including software-properties-common | |
RUN apt-get update && apt-get install -y \ | |
wget \ | |
ca-certificates \ | |
ffmpeg \ | |
libsm6 \ | |
libxext6 \ | |
software-properties-common \ | |
git | |
RUN apt-get -y install cudnn-cuda-12 | |
# Add the deadsnakes PPA to get Python 3.11 packages | |
RUN add-apt-repository ppa:deadsnakes/ppa && apt-get update | |
# Install Python 3.11 and related packages | |
RUN apt-get install -y \ | |
python3.11 \ | |
python3.11-venv \ | |
python3.11-dev \ | |
python3.11-distutils | |
# Install pip for Python 3.11 using get-pip.py | |
RUN wget https://bootstrap.pypa.io/get-pip.py && \ | |
python3.11 get-pip.py && \ | |
rm get-pip.py | |
# (Optional) Verify pip installation | |
RUN python3.11 -m pip --version | |
# Update LD_LIBRARY_PATH to include CUDA/cuDNN libraries | |
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH | |
# Create and switch to a non-root user | |
RUN useradd -m -u 1000 user | |
USER user | |
ENV PATH="/home/user/.local/bin:$PATH" | |
WORKDIR /app | |
# Copy the requirements and install Python dependencies | |
COPY --chown=user ./requirements.txt requirements.txt | |
RUN python3.11 -m pip install --no-cache-dir --upgrade pip && \ | |
python3.11 -m pip install --no-cache-dir -r requirements.txt | |
# Copy the application code | |
COPY --chown=user . /app | |
# Start the application | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |