-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
89 lines (77 loc) · 2.65 KB
/
Dockerfile
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
FROM nvidia/cuda:12.3.1-runtime-ubuntu22.04
WORKDIR /usr/src/app
# Set timezone
ENV TZ=Europe/London
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Install dependencies
RUN apt-get update \
&& apt-get install -y \
python3 \
python3-pip \
gcc-9 g++-9 \
git \
build-essential \
cmake \
libgtk2.0-dev \
pkg-config \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
python3-dev \
python3-numpy \
nvidia-cuda-toolkit \
&& rm -rf /var/lib/apt/lists/*
# Install Python packages
COPY requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt
# Install cuDNN
COPY cudnn-local-repo-ubuntu2204-8.9.7.29_1.0-1_amd64.deb /tmp
RUN dpkg -i /tmp/cudnn-local-repo-ubuntu2204-8.9.7.29_1.0-1_amd64.deb
RUN cp /var/cudnn-local-repo-ubuntu2204-8.9.7.29/cudnn-local-8AE81B24-keyring.gpg /usr/share/keyrings/
RUN apt-get update \
&& apt-get install -y libcudnn8=8.9.7.29-1+cuda11.8 libcudnn8-dev=8.9.7.29-1+cuda11.8 \
&& rm -rf /var/lib/apt/lists/* \
&& rm /tmp/cudnn-local-repo-ubuntu2204-8.9.7.29_1.0-1_amd64.deb
# Clone and build OpenCV from source
RUN git clone https://github.com/opencv/opencv.git \
&& git clone https://github.com/opencv/opencv_contrib.git \
&& cd opencv \
&& mkdir build \
&& cd build \
&& cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu/ \
-D CUDA_HOST_COMPILER=/usr/bin/gcc-9 \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D WITH_CUDA=ON \
-D CUDA_ARCH_BIN=5.2 \
-D CUDA_ARCH_PTX="" \
-D BUILD_opencv_cudacodec=OFF \
-D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 \
-D WITH_CUBLAS=1 \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-D BUILD_EXAMPLES=OFF .. \
&& make -j$(nproc) \
&& make install \
&& ldconfig \
&& cd ../../ \
&& rm -rf opencv opencv_contrib
# Clone and build dlib from source with CUDA support
RUN git clone https://github.com/davisking/dlib.git \
&& cd dlib \
&& mkdir build \
&& cd build \
&& cmake .. -DDLIB_USE_CUDA=1 -DUSE_AVX_INSTRUCTIONS=1 -DCUDA_HOST_COMPILER=/usr/bin/gcc-9 -DCMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu/ \
&& cmake --build . \
&& cd .. \
&& python3 setup.py install \
&& cd .. \
&& rm -rf dlib
RUN pip install face-recognition
COPY . .
RUN chmod +x start.sh
EXPOSE 8000
ENV PYTHONUNBUFFERED 1
CMD ["./start.sh"]