KEEP-docker / Dockerfile
fffiloni's picture
Update Dockerfile
0a57c89 verified
raw
history blame
2.41 kB
FROM pytorch/pytorch:2.1.2-cuda11.8-cudnn8-devel
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
cmake \
build-essential \
libgl1-mesa-glx \
libglib2.0-0 \
ffmpeg \
python3.8 \
python3-pip \
python3.8-dev \
&& rm -rf /var/lib/apt/lists/*
# Create a symlink for python
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
PYTHONPATH=$HOME/app \
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 CUDA_HOME environment variable
ENV CUDA_HOME=/usr/local/cuda-11.8
ENV TORCH_CUDA_ARCH_LIST="6.0;6.1;7.0;7.5;8.0;8.6+PTX;8.9;9.0"
ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
# Set the environment variable to specify the GPU device
ENV CUDA_DEVICE_ORDER=PCI_BUS_ID
ENV CUDA_VISIBLE_DEVICES=0
# Set the working directory to the user's home directory
WORKDIR $HOME/app
# Install system dependencies as root
USER root
# Set Python 3.8 as the default python and pip versions
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
RUN update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
# Clone the repository (adjust the URL if needed)
RUN git clone --recursive https://github.com/jnjaby/KEEP.git $HOME/app
# Set Git ownership for the cloned repository
USER root
RUN git config --global --add safe.directory $HOME/app
USER user
# Copy the app.py script into the container
COPY app.py .
COPY requirements_HF.txt .
# Install Python dependencies from requirements.txt
RUN pip install --upgrade pip
RUN pip install -r requirements_HF.txt
RUN pip install gradio
RUN pip install "numpy<1.25,>=1.18"
RUN pip install cupy==10.4.0
USER root
# Install basicsr
RUN cd $HOME/app && \
if [ -d "basicsr" ]; then \
cd basicsr && \
if [ ! -f "basicsr/VERSION" ]; then \
echo "1.3.2" > basicsr/VERSION; \
fi && \
python setup.py develop; \
else \
echo "basicsr directory not found"; \
exit 1; \
fi
USER user
# Install additional Python packages
RUN pip install ffmpeg-python
RUN pip install dlib
# Command to run your application
CMD ["python", "app.py"]