File size: 2,488 Bytes
d562dad 013a047 c813a1c d562dad c813a1c cecc2bd 692d4e7 c813a1c d562dad c813a1c d562dad 334c7de 8864a7f 334c7de cecc2bd 013a047 eb5809d 6c2a0d6 ccc9126 c813a1c d562dad eb5809d e2f7be5 6c2a0d6 d562dad 334c7de |
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# Use the NVIDIA CUDA runtime as a base image
FROM nvidia/cuda:11.8.0-devel-ubuntu22.04
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
CUDA_HOME=/usr/local/cuda \
PATH=/home/user/.local/bin:$PATH \
LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH} \
LIBRARY_PATH=${CUDA_HOME}/lib64/stubs:${LIBRARY_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 the working directory to the user's home directory
WORKDIR $HOME/app
# Install system dependencies as root
USER root
# Install basic utilities, Python 3.9, graphical libraries, and add NVIDIA cuDNN repository
RUN apt-get update && apt-get install -y \
wget \
curl \
git \
software-properties-common \
gnupg \
libgl1-mesa-glx \
libglib2.0-0 \
&& add-apt-repository ppa:deadsnakes/ppa -y && \
apt-get update && apt-get install -y \
python3.9 \
python3.9-distutils \
python3.9-dev \
&& curl -sS https://bootstrap.pypa.io/get-pip.py | python3.9 \
&& update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1 \
&& update-alternatives --install /usr/bin/pip pip /usr/local/bin/pip 1 \
&& curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub | gpg --batch --yes --dearmor -o /usr/share/keyrings/cuda-archive-keyring.gpg && \
echo "deb [signed-by=/usr/share/keyrings/cuda-archive-keyring.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ /" > /etc/apt/sources.list.d/cuda.list && \
apt-get update && apt-get install -y \
cudnn-cuda-11 \
&& rm -rf /var/lib/apt/lists/*
# Verify cuDNN installation
RUN dpkg-query -W libcudnn9
# Verify Python and pip versions
RUN python --version && pip --version
USER user
# Copy dependencies and install them via pip
COPY . .
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
RUN pip install gradio
USER root
# Configure git to trust the directory
RUN git config --global --add safe.directory /home/user/app
RUN chown -R user:user /home/user/app
USER user
# Set the environment variable to specify the GPU device
ENV CUDA_DEVICE_ORDER=PCI_BUS_ID
ENV CUDA_VISIBLE_DEVICES=0
# Command to run your application
CMD ["python", "app.py"]
|