Spaces:
Running
on
Zero
Running
on
Zero
Create Dockerfile
Browse files- Dockerfile +66 -0
Dockerfile
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use the NVIDIA CUDA runtime as a base image
|
| 2 |
+
FROM nvidia/cuda:11.8.0-devel-ubuntu22.04
|
| 3 |
+
|
| 4 |
+
# Set environment variables
|
| 5 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 6 |
+
|
| 7 |
+
RUN useradd -m -u 1000 user
|
| 8 |
+
|
| 9 |
+
USER user
|
| 10 |
+
|
| 11 |
+
ENV HOME=/home/user \
|
| 12 |
+
CUDA_HOME=/usr/local/cuda \
|
| 13 |
+
PATH=/home/user/.local/bin:$PATH \
|
| 14 |
+
LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH} \
|
| 15 |
+
LIBRARY_PATH=${CUDA_HOME}/lib64/stubs:${LIBRARY_PATH} \
|
| 16 |
+
PYTHONPATH=$HOME/app \
|
| 17 |
+
PYTHONUNBUFFERED=1 \
|
| 18 |
+
GRADIO_ALLOW_FLAGGING=never \
|
| 19 |
+
GRADIO_NUM_PORTS=1 \
|
| 20 |
+
GRADIO_SERVER_NAME=0.0.0.0 \
|
| 21 |
+
GRADIO_THEME=huggingface \
|
| 22 |
+
GRADIO_SHARE=False \
|
| 23 |
+
SYSTEM=spaces
|
| 24 |
+
|
| 25 |
+
# Set the working directory to the user's home directory
|
| 26 |
+
WORKDIR $HOME/app
|
| 27 |
+
|
| 28 |
+
# Install system dependencies as root
|
| 29 |
+
USER root
|
| 30 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 31 |
+
git \
|
| 32 |
+
cmake \
|
| 33 |
+
build-essential \
|
| 34 |
+
libgl1-mesa-glx \
|
| 35 |
+
libglib2.0-0 \
|
| 36 |
+
ffmpeg \
|
| 37 |
+
python3.9 \
|
| 38 |
+
python3-pip \
|
| 39 |
+
python3.9-dev \
|
| 40 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 41 |
+
|
| 42 |
+
# Set Python 3.9 as the default python and pip versions
|
| 43 |
+
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1
|
| 44 |
+
RUN update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
|
| 45 |
+
|
| 46 |
+
USER user
|
| 47 |
+
# Copy dependencies and install them via pip
|
| 48 |
+
COPY . .
|
| 49 |
+
RUN pip install --upgrade pip
|
| 50 |
+
RUN pip install -r requirements.txt
|
| 51 |
+
RUN pip install gradio
|
| 52 |
+
|
| 53 |
+
USER root
|
| 54 |
+
# Configure git to trust the directory
|
| 55 |
+
RUN git config --global --add safe.directory /home/user/app
|
| 56 |
+
RUN chown -R user:user /home/user/app
|
| 57 |
+
|
| 58 |
+
USER user
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
# Set the environment variable to specify the GPU device
|
| 62 |
+
ENV CUDA_DEVICE_ORDER=PCI_BUS_ID
|
| 63 |
+
ENV CUDA_VISIBLE_DEVICES=0
|
| 64 |
+
|
| 65 |
+
# Command to run your application
|
| 66 |
+
CMD ["python", "app.py"]
|