Spaces:
Paused
Paused
# Use the NVIDIA CUDA runtime as a base image | |
FROM nvidia/cuda:11.3.1-cudnn8-devel-ubuntu20.04 | |
# Set environment variables | |
ENV DEBIAN_FRONTEND=noninteractive | |
# Create a non-root user | |
RUN useradd -m -u 1000 user | |
# Install system dependencies as root | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
git \ | |
cmake \ | |
ninja-build \ | |
build-essential \ | |
libgl1-mesa-glx \ | |
libglib2.0-0 \ | |
ffmpeg \ | |
python3.9 \ | |
python3-pip \ | |
python3.9-dev \ | |
python3.9-venv \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Set Python 3.9 as the default python and pip versions | |
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1 | |
RUN update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 | |
# Switch to non-root user | |
USER user | |
# Create virtual environment | |
RUN python -m venv /home/user/venv | |
ENV VIRTUAL_ENV=/home/user/venv | |
ENV PATH="$VIRTUAL_ENV/bin:$PATH" | |
# Set environment variables | |
ENV HOME=/home/user \ | |
CUDA_HOME=/usr/local/cuda \ | |
LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH} \ | |
LIBRARY_PATH=${CUDA_HOME}/lib64/stubs:${LIBRARY_PATH} \ | |
PYTHONUNBUFFERED=1 \ | |
GRADIO_ALLOW_FLAGGING=never \ | |
GRADIO_NUM_PORTS=1 \ | |
GRADIO_SERVER_NAME=0.0.0.0 \ | |
GRADIO_THEME=huggingface \ | |
GRADIO_SHARE=False \ | |
SYSTEM=spaces | |
# Set working directory | |
WORKDIR $HOME/app | |
# Upgrade pip and install numpy<2 first, then PyTorch | |
RUN pip install --no-cache-dir --upgrade pip && \ | |
pip install --no-cache-dir "numpy<2" && \ | |
pip install --no-cache-dir torch==1.7.1 torchvision --extra-index-url https://download.pytorch.org/whl/cu113 && \ | |
python -c "import torch; print('PyTorch version:', torch.__version__)" | |
# Clone the repository | |
RUN git clone --recursive https://github.com/jnjaby/KEEP.git . | |
# Copy application files | |
COPY app.py . | |
COPY requirements_HF.txt . | |
# Install Python dependencies | |
RUN pip install --no-cache-dir -r requirements_HF.txt | |
RUN pip install --no-cache-dir gradio | |
# Install Cython (needed for some dependencies) | |
RUN pip install --no-cache-dir cython==0.29.36 | |
# Install basicsr with selective warnings | |
RUN BASICSR_EXT=True CFLAGS="-Wno-deprecated-declarations" python basicsr/setup.py develop | |
# Install additional packages | |
RUN pip install --no-cache-dir ffmpeg-python dlib | |
# Set CUDA device settings | |
ENV CUDA_DEVICE_ORDER=PCI_BUS_ID | |
ENV CUDA_VISIBLE_DEVICES=0 | |
# Command to run the application | |
CMD ["python", "app.py"] |