From e8704e16a32338343e18f8e2a076cc530978b6a0 Mon Sep 17 00:00:00 2001 From: Irina_Exadel Date: Tue, 31 Aug 2021 17:22:10 +0300 Subject: [PATCH] added Dockerfile with coral TPU access --- embedding-calculator/tpu.Dockerfile.full | 82 ++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 embedding-calculator/tpu.Dockerfile.full diff --git a/embedding-calculator/tpu.Dockerfile.full b/embedding-calculator/tpu.Dockerfile.full new file mode 100644 index 0000000000..17e1e78ae9 --- /dev/null +++ b/embedding-calculator/tpu.Dockerfile.full @@ -0,0 +1,82 @@ +FROM debian:buster-slim + +RUN apt-get update + +RUN apt-get install --no-install-recommends -y \ + gnupg \ + ca-certificates \ + curl \ + apt-utils \ + apt-transport-https + +# Python package management and basic dependencies +RUN apt-get install -y curl python3.7 python3.7-dev python3.7-distutils + +# Set python 3 as the default python +RUN update-alternatives --set python /usr/bin/python3.7 + +# Upgrade pip to latest version +RUN curl -s https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \ + python get-pip.py --force-reinstall && \ + rm get-pip.py + +RUN apt-get update && apt-get install -y build-essential cmake git wget unzip \ + curl yasm pkg-config libswscale-dev libtbb2 libtbb-dev libjpeg-dev \ + libpng-dev libtiff-dev libavformat-dev libpq-dev libfreeimage3 \ + && rm -rf /var/lib/apt/lists/* + +# install drivers for coral tpu +RUN echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | tee /etc/apt/sources.list.d/coral-edgetpu.list +RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - +RUN apt-get update && apt-get install -y libedgetpu1-std + +# install common python packages +SHELL ["/bin/bash", "-c"] +WORKDIR /app/ml +COPY requirements.txt . +RUN pip --no-cache-dir install -r requirements.txt + +ARG BE_VERSION +ARG APP_VERSION_STRING +ENV BE_VERSION=$BE_VERSION +ENV APP_VERSION_STRING=$APP_VERSION_STRING +ENV HOME=/app/ml +ENV LC_ALL=C.UTF-8 +ENV LANG=C.UTF-8 +ENV PYTHONUNBUFFERED=0 +ENV JOBLIB_MULTIPROCESSING=0 + +# download ML models +ARG INTEL_OPTIMIZATION=false +ARG GPU_IDX=-1 +ENV GPU_IDX=$GPU_IDX INTEL_OPTIMIZATION=$INTEL_OPTIMIZATION +ARG FACE_DETECTION_PLUGIN="facenet.coralmtcnn.FaceDetector" +ARG CALCULATION_PLUGIN="facenet.coralmtcnn.Calculator" +ARG EXTRA_PLUGINS="facenet.LandmarksDetector,agegender.AgeDetector,agegender.GenderDetector,facenet.facemask.MaskDetector" +ENV FACE_DETECTION_PLUGIN=$FACE_DETECTION_PLUGIN CALCULATION_PLUGIN=$CALCULATION_PLUGIN \ + EXTRA_PLUGINS=$EXTRA_PLUGINS +COPY src src +COPY srcext srcext +RUN pip --no-cache-dir install srcext/mtcnn_tflite/ +RUN python -m src.services.facescan.plugins.setup + +# copy rest of the code +COPY tools tools +COPY sample_images sample_images + +# run tests +ARG SKIP_TESTS +COPY pytest.ini . +RUN if [ -z $SKIP_TESTS ]; then pytest -m "not performance" /app/ml/src; fi + +# create folder for tflite model +RUN mkdir -p /app/ml/.cache/mtcnn-tflite-models +RUN chmod a+rwx -R /app/ml/.cache/mtcnn-tflite-models +USER root + +EXPOSE 3000 + +COPY uwsgi.ini . +ENV UWSGI_PROCESSES=${UWSGI_PROCESSES:-2} +ENV UWSGI_THREADS=1 +CMD ["uwsgi", "--ini", "uwsgi.ini"]