Skip to content

Commit

Permalink
added Dockerfile with coral TPU access
Browse files Browse the repository at this point in the history
  • Loading branch information
iamrinni authored and ammgws committed May 26, 2024
1 parent 1673675 commit 1987d96
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions embedding-calculator/tpu.Dockerfile.full
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit 1987d96

Please sign in to comment.