-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
83 lines (73 loc) · 3 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
FROM nvcr.io/nvidia/cuda:11.3.1-cudnn8-devel-ubuntu20.04 as build
ENV DEBIAN_FRONTEND=noninteractive
ENV OPENCV_VERSION=4.8.0
ENV VIRTUAL_ENV=/opt/.venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential gcc g++ git wget cmake unzip pkg-config \
python3 python3-dev \
python3-setuptools python3-pip python3-venv \
libavcodec-dev libavformat-dev libswscale-dev \
libpng-dev libjpeg-dev libopenexr-dev libtiff-dev libwebp-dev \
libopenblas-dev libatlas-base-dev liblapack-dev gfortran \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /opt
RUN python3 -m venv .venv && \
pip3 install wheel numpy
RUN wget https://github.com/opencv/opencv/archive/$OPENCV_VERSION.zip &&\
unzip $OPENCV_VERSION.zip &&\
rm $OPENCV_VERSION.zip &&\
wget https://github.com/opencv/opencv_contrib/archive/$OPENCV_VERSION.zip &&\
unzip ${OPENCV_VERSION}.zip &&\
rm ${OPENCV_VERSION}.zip &&\
mkdir /opt/opencv-${OPENCV_VERSION}/build && cd /opt/opencv-${OPENCV_VERSION}/build &&\
cmake \
-D OPENCV_EXTRA_MODULES_PATH=/opt/opencv_contrib-${OPENCV_VERSION}/modules \
-D WITH_CUDA=ON \
-D WITH_CUDNN=ON \
-D OPENCV_DNN_CUDA=ON \
-D ENABLE_FAST_MATH=ON \
-D CUDA_FAST_MATH=ON \
-D WITH_CUBLAS=ON \
-D CUDA_ARCH_BIN=5.3,6.1,7.0,7.2,7.5,8.6 \
-D BUILD_OPENCV_PYTHON3=ON \
-D BUILD_OPENCV_PYTHON2=OFF \
-D BUILD_OPENCV_JAVA=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_IPP_IW=OFF \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_EXAMPLES=OFF \
-D BUILD_ANDROID_EXAMPLES=OFF \
-D BUILD_DOCS=OFF \
-D BUILD_ITT=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_TESTS=OFF \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=${VIRTUAL_ENV} \
-D PYTHON_EXECUTABLE=${VIRTUAL_ENV}/bin/python3 \
-D PYTHON_PACKAGES_PATH=${VIRTUAL_ENV}/lib/python3.8/site-packages \
.. && \
make -j4 && \
make install && \
ldconfig && \
rm -rf /opt/opencv-${OPENCV_VERSION} && \
rm -rf /opt/opencv_contrib-${OPENCV_VERSION}
WORKDIR /opt/is-face-detector
COPY . .
RUN pip3 install . && \
cd etc/model/ && \
./download_models.sh && \
cd ../../
FROM nvcr.io/nvidia/cuda:11.3.1-cudnn8-runtime-ubuntu20.04
COPY --from=build /opt/.venv /opt/.venv
COPY --from=build /opt/is-face-detector/etc/model /opt/is-face-detector/etc/model
COPY --from=build /opt/is-face-detector/etc/conf/options.json /etc/is-face-detector/options.json
ENV VIRTUAL_ENV=/opt/.venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN apt-get update && \
apt-get install --no-install-recommends -y python3 \
libavcodec-dev libavformat-dev libswscale-dev \
libpng-dev libjpeg-dev libopenexr-dev libtiff-dev libwebp-dev && \
rm -rf /var/lib/apt/lists/*
CMD [ "is-face-detector-stream", "/etc/is-face-detector/options.json" ]