-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.cuda
69 lines (55 loc) · 2.1 KB
/
Dockerfile.cuda
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
# Use the NVIDIA CUDA image as the base
FROM nvidia/cuda:12.0.1-cudnn8-devel-ubuntu22.04
# Set the working directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3.11 \
python3-pip \
build-essential \
libssl-dev \
libffi-dev \
libjpeg-dev \
zlib1g-dev \
libpng-dev \
libsentencepiece-dev \
curl \
gcc \
g++ \
python3.11-dev \
cmake \
&& rm -rf /var/lib/apt/lists/*
# Set Python 3.11 as the default
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1
# Upgrade pip and install base packages
RUN pip install --upgrade pip setuptools wheel
# Set PYTHONPATH correctly
ENV PYTHONPATH=/app
# Install PyTorch with CUDA support
RUN pip3 install --no-cache-dir \
torch \
torchvision \
torchaudio \
--index-url https://download.pytorch.org/whl/cu124
# Copy the requirements file
COPY requirements_cuda.txt .
# Install additional Python dependencies
RUN pip3 install --no-cache-dir -r requirements_cuda.txt
# Copy the rest of the application code
COPY . .
# Set environment variables for better GPU memory handling and protobuf implementation
ENV PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:512
ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
ENV PYTHONUNBUFFERED=1
# Set up the environment and logging
RUN python -m pip install --upgrade pip && \
python -c "from config.env_config import setup_environment; setup_environment()"
RUN python -c "from pathlib import Path; from config.logging_config import setup_logging; setup_logging(Path('flux_pipeline.log'))"
# Expose the application port
EXPOSE 7860
# Healthcheck to verify Gradio service status
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:7860/ || exit 1
# Set the command to run the application with updated arguments
CMD ["python3", "-u", "gui.py", "--host", "0.0.0.0", "--port", "7860", "--share"]