2024-01-22 01:22:39 +02:00
|
|
|
ARG DEVICE=cpu
|
2023-06-16 17:28:41 +02:00
|
|
|
|
2024-08-03 15:24:09 +02:00
|
|
|
FROM python:3.11-bookworm@sha256:f89d36dbb4728313572f88877b8be7d11fd03bea964cdf0a6b0f61edfcde3709 as builder-cpu
|
2024-01-22 01:22:39 +02:00
|
|
|
|
2024-07-22 01:30:24 +02:00
|
|
|
FROM builder-cpu as builder-openvino
|
2024-01-22 01:22:39 +02:00
|
|
|
|
|
|
|
FROM builder-cpu as builder-cuda
|
|
|
|
|
|
|
|
FROM builder-cpu as builder-armnn
|
|
|
|
|
|
|
|
ENV ARMNN_PATH=/opt/armnn
|
|
|
|
COPY ann /opt/ann
|
|
|
|
RUN mkdir /opt/armnn && \
|
2024-07-20 21:59:27 +02:00
|
|
|
curl -SL "https://github.com/ARM-software/armnn/releases/download/v24.05/ArmNN-linux-aarch64.tar.gz" | tar -zx -C /opt/armnn && \
|
2024-01-22 01:22:39 +02:00
|
|
|
cd /opt/ann && \
|
|
|
|
sh build.sh
|
|
|
|
|
|
|
|
FROM builder-${DEVICE} as builder
|
|
|
|
|
|
|
|
ARG DEVICE
|
2023-03-04 00:45:20 +02:00
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
2024-03-16 06:04:45 +02:00
|
|
|
PYTHONUNBUFFERED=1 \
|
|
|
|
PIP_NO_CACHE_DIR=true \
|
|
|
|
VIRTUAL_ENV="/opt/venv" \
|
|
|
|
PATH="/opt/venv/bin:${PATH}"
|
|
|
|
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends g++
|
2023-03-01 17:37:12 +02:00
|
|
|
|
2023-06-05 16:40:48 +02:00
|
|
|
RUN pip install --upgrade pip && pip install poetry
|
|
|
|
RUN poetry config installer.max-workers 10 && \
|
2024-01-22 01:22:39 +02:00
|
|
|
poetry config virtualenvs.create false
|
|
|
|
RUN python3 -m venv /opt/venv
|
2023-03-04 00:45:20 +02:00
|
|
|
|
2023-10-31 12:02:04 +02:00
|
|
|
COPY poetry.lock pyproject.toml ./
|
2024-01-22 01:22:39 +02:00
|
|
|
RUN poetry install --sync --no-interaction --no-ansi --no-root --with ${DEVICE} --without dev
|
2023-03-01 19:48:35 +02:00
|
|
|
|
2024-08-03 15:24:09 +02:00
|
|
|
FROM python:3.11-slim-bookworm@sha256:7f49f147e57a65a5ca731203ed350ac5c88fa54aeb942924dd7057fe34a18e79 as prod-cpu
|
2023-06-16 17:28:41 +02:00
|
|
|
|
2024-07-22 01:30:24 +02:00
|
|
|
FROM prod-cpu as prod-openvino
|
2024-01-22 01:22:39 +02:00
|
|
|
|
2024-07-22 01:30:24 +02:00
|
|
|
COPY scripts/configure-apt.sh ./
|
|
|
|
RUN ./configure-apt.sh && \
|
|
|
|
apt-get update && \
|
|
|
|
apt-get install -t unstable --no-install-recommends -yqq intel-opencl-icd && \
|
|
|
|
rm configure-apt.sh
|
|
|
|
|
|
|
|
FROM nvidia/cuda:12.3.2-cudnn9-runtime-ubuntu22.04@sha256:fa44193567d1908f7ca1f3abf8623ce9c63bc8cba7bcfdb32702eb04d326f7a8 as prod-cuda
|
2024-01-11 19:26:46 +02:00
|
|
|
|
2024-01-22 01:22:39 +02:00
|
|
|
COPY --from=builder-cuda /usr/local/bin/python3 /usr/local/bin/python3
|
|
|
|
COPY --from=builder-cuda /usr/local/lib/python3.11 /usr/local/lib/python3.11
|
|
|
|
COPY --from=builder-cuda /usr/local/lib/libpython3.11.so /usr/local/lib/libpython3.11.so
|
2024-01-11 19:26:46 +02:00
|
|
|
|
2024-01-22 01:22:39 +02:00
|
|
|
FROM prod-cpu as prod-armnn
|
2023-07-21 16:20:04 +02:00
|
|
|
|
2024-01-22 01:22:39 +02:00
|
|
|
ENV LD_LIBRARY_PATH=/opt/armnn
|
|
|
|
|
2024-07-20 21:59:27 +02:00
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends ocl-icd-libopencl1 mesa-opencl-icd libgomp1 && \
|
2024-01-11 19:26:46 +02:00
|
|
|
rm -rf /var/lib/apt/lists/* && \
|
|
|
|
mkdir --parents /etc/OpenCL/vendors && \
|
2024-02-12 20:29:55 +02:00
|
|
|
echo "/usr/lib/libmali.so" > /etc/OpenCL/vendors/mali.icd && \
|
|
|
|
mkdir /opt/armnn
|
2024-01-22 01:22:39 +02:00
|
|
|
|
|
|
|
COPY --from=builder-armnn \
|
2024-03-16 06:04:45 +02:00
|
|
|
/opt/armnn/libarmnn.so.?? \
|
|
|
|
/opt/armnn/libarmnnOnnxParser.so.?? \
|
|
|
|
/opt/armnn/libarmnnDeserializer.so.?? \
|
|
|
|
/opt/armnn/libarmnnTfLiteParser.so.?? \
|
|
|
|
/opt/armnn/libprotobuf.so.?.??.?.? \
|
|
|
|
/opt/ann/libann.s[o] \
|
|
|
|
/opt/ann/build.sh \
|
|
|
|
/opt/armnn/
|
2024-01-22 01:22:39 +02:00
|
|
|
|
|
|
|
FROM prod-${DEVICE} as prod
|
2024-07-22 01:30:24 +02:00
|
|
|
ARG DEVICE
|
2024-01-22 01:22:39 +02:00
|
|
|
|
|
|
|
RUN apt-get update && \
|
2024-07-22 01:30:24 +02:00
|
|
|
apt-get install -y --no-install-recommends tini $(if ! [ "$DEVICE" = "openvino" ]; then echo "libmimalloc2.0"; fi) && \
|
|
|
|
apt-get autoremove -yqq && \
|
|
|
|
apt-get clean && \
|
2024-01-22 01:22:39 +02:00
|
|
|
rm -rf /var/lib/apt/lists/*
|
2024-01-11 19:26:46 +02:00
|
|
|
|
2023-06-05 16:40:48 +02:00
|
|
|
WORKDIR /usr/src/app
|
2024-05-17 19:30:05 +02:00
|
|
|
ENV TRANSFORMERS_CACHE=/cache \
|
2024-03-16 06:04:45 +02:00
|
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
|
|
|
PYTHONUNBUFFERED=1 \
|
|
|
|
PATH="/opt/venv/bin:$PATH" \
|
|
|
|
PYTHONPATH=/usr/src \
|
|
|
|
DEVICE=${DEVICE}
|
2023-03-01 19:48:35 +02:00
|
|
|
|
2023-12-17 04:30:29 +02:00
|
|
|
# prevent core dumps
|
|
|
|
RUN echo "hard core 0" >> /etc/security/limits.conf && \
|
|
|
|
echo "fs.suid_dumpable 0" >> /etc/sysctl.conf && \
|
|
|
|
echo 'ulimit -S -c 0 > /dev/null 2>&1' >> /etc/profile
|
|
|
|
|
2023-06-05 16:40:48 +02:00
|
|
|
COPY --from=builder /opt/venv /opt/venv
|
2024-01-11 19:26:46 +02:00
|
|
|
COPY ann/ann.py /usr/src/ann/ann.py
|
2023-09-01 01:30:53 +02:00
|
|
|
COPY start.sh log_conf.json ./
|
2023-06-05 16:40:48 +02:00
|
|
|
COPY app .
|
2023-07-21 16:20:04 +02:00
|
|
|
ENTRYPOINT ["tini", "--"]
|
2023-09-01 01:30:53 +02:00
|
|
|
CMD ["./start.sh"]
|
2024-05-22 18:54:29 +02:00
|
|
|
|
|
|
|
HEALTHCHECK CMD python3 healthcheck.py
|