-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.gpu
More file actions
92 lines (74 loc) · 2.59 KB
/
Dockerfile.gpu
File metadata and controls
92 lines (74 loc) · 2.59 KB
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
83
84
85
86
87
88
89
90
91
92
# Stage 1: Build stage with CUDA development toolkit
FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu20.04 AS builder
# Set environment variables to non-interactive
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Etc/UTC
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
cmake \
libopenblas-dev \
liblapack-dev \
libjpeg-dev \
libpng-dev \
python3 \
python3-pip \
python3-dev \
git \
&& rm -rf /var/lib/apt/lists/*
# Set python3 as default python
RUN ln -s /usr/bin/python3 /usr/bin/python
# Create and set the working directory for the build
WORKDIR /app
# Copy requirements to install dependencies
COPY requirements.in .
# Set environment variable to force a CUDA-enabled build of dlib
ENV DLIB_USE_CUDA=1
# Check for nvcc and then clone, build, and install dlib from source.
# We use a specific release tag for stability and build with cmake directly
# to ensure CUDA is used.
RUN which nvcc
RUN git clone -b v19.24 https://github.com/davisking/dlib.git dlib
WORKDIR /app/dlib
RUN mkdir build
WORKDIR /app/dlib/build
RUN cmake .. -DDLIB_USE_CUDA=1 -DUSE_AVX_INSTRUCTIONS=1
RUN cmake --build .
WORKDIR /app/dlib
RUN pip3 install .
WORKDIR /app
# Verify that dlib was compiled with CUDA support before proceeding.
RUN python3 -c "import dlib; assert dlib.DLIB_USE_CUDA, 'dlib was NOT built with CUDA support'"
# Now that dlib is correctly installed, install the rest of the requirements
RUN pip3 install --no-cache-dir -r requirements.in
# ---
# Stage 2: Final runtime stage
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu20.04
# Set environment variables to non-interactive
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Etc/UTC
# Install only necessary runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
libopenblas-dev \
liblapack-dev \
libjpeg-dev \
libpng-dev \
libx11-dev \
libgtk-3-dev \
python3 \
python3-pip \
&& rm -rf /var/lib/apt/lists/*
# Set python3 as default python
RUN ln -s /usr/bin/python3 /usr/bin/python
# Create and set the working directory
WORKDIR /app
# Copy the installed python packages from the builder stage
COPY --from=builder /usr/local/lib/python3.8/dist-packages /usr/local/lib/python3.8/dist-packages
COPY --from=builder /usr/local/bin /usr/local/bin
# Copy the application source code into the container
COPY ./facesorter ./facesorter
COPY config.yaml .
# Expose the port the app runs on
EXPOSE 7860
# Define the command to run the application
CMD ["streamlit", "run", "facesorter/app.py", "--server.address=0.0.0.0", "--server.port=7860"]