2024-01-21 23:22:39 +00:00
|
|
|
ARG DEVICE=cpu
|
2023-06-16 15:28:41 +00:00
|
|
|
|
2024-12-16 15:03:04 +00:00
|
|
|
FROM python:3.11-bookworm@sha256:2c80c66d876952e04fa74113864903198b7cfb36b839acb7a8fef82e94ed067c AS builder-cpu
|
2024-01-21 23:22:39 +00:00
|
|
|
|
2024-08-05 12:07:28 +00:00
|
|
|
FROM builder-cpu AS builder-openvino
|
2024-01-21 23:22:39 +00:00
|
|
|
|
2024-08-05 12:07:28 +00:00
|
|
|
FROM builder-cpu AS builder-cuda
|
2024-01-21 23:22:39 +00:00
|
|
|
|
2024-08-05 12:07:28 +00:00
|
|
|
FROM builder-cpu AS builder-armnn
|
2024-01-21 23:22:39 +00:00
|
|
|
|
|
|
|
ENV ARMNN_PATH=/opt/armnn
|
|
|
|
COPY ann /opt/ann
|
|
|
|
RUN mkdir /opt/armnn && \
|
2024-07-20 19:59:27 +00: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-21 23:22:39 +00:00
|
|
|
cd /opt/ann && \
|
|
|
|
sh build.sh
|
|
|
|
|
2024-08-05 12:07:28 +00:00
|
|
|
FROM builder-${DEVICE} AS builder
|
2024-01-21 23:22:39 +00:00
|
|
|
|
|
|
|
ARG DEVICE
|
2023-03-03 22:45:20 +00:00
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
2024-03-16 04:04:45 +00: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 15:37:12 +00:00
|
|
|
|
2023-06-05 14:40:48 +00:00
|
|
|
RUN pip install --upgrade pip && pip install poetry
|
|
|
|
RUN poetry config installer.max-workers 10 && \
|
2024-01-21 23:22:39 +00:00
|
|
|
poetry config virtualenvs.create false
|
|
|
|
RUN python3 -m venv /opt/venv
|
2023-03-03 22:45:20 +00:00
|
|
|
|
2023-10-31 10:02:04 +00:00
|
|
|
COPY poetry.lock pyproject.toml ./
|
2024-01-21 23:22:39 +00:00
|
|
|
RUN poetry install --sync --no-interaction --no-ansi --no-root --with ${DEVICE} --without dev
|
2023-03-01 17:48:35 +00:00
|
|
|
|
2024-12-16 15:03:04 +00:00
|
|
|
FROM python:3.11-slim-bookworm@sha256:370c586a6ffc8c619e6d652f81c094b34b14b8f2fb9251f092de23f16e299b78 AS prod-cpu
|
2023-06-16 15:28:41 +00:00
|
|
|
|
2024-08-05 12:07:28 +00:00
|
|
|
FROM prod-cpu AS prod-openvino
|
2024-01-21 23:22:39 +00:00
|
|
|
|
2024-08-15 18:27:18 +00:00
|
|
|
RUN apt-get update && \
|
|
|
|
apt-get install --no-install-recommends -yqq ocl-icd-libopencl1 wget && \
|
2024-09-08 03:08:11 +00:00
|
|
|
wget https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.17384.11/intel-igc-core_1.0.17384.11_amd64.deb && \
|
|
|
|
wget https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.17384.11/intel-igc-opencl_1.0.17384.11_amd64.deb && \
|
|
|
|
wget https://github.com/intel/compute-runtime/releases/download/24.31.30508.7/intel-opencl-icd_24.31.30508.7_amd64.deb && \
|
|
|
|
wget https://github.com/intel/compute-runtime/releases/download/24.31.30508.7/libigdgmm12_22.4.1_amd64.deb && \
|
2024-08-15 18:27:18 +00:00
|
|
|
dpkg -i *.deb && \
|
|
|
|
rm *.deb && \
|
|
|
|
apt-get remove wget -yqq && \
|
|
|
|
rm -rf /var/lib/apt/lists/*
|
2024-07-21 23:30:24 +00:00
|
|
|
|
2024-09-12 00:25:57 +00:00
|
|
|
FROM nvidia/cuda:12.2.2-runtime-ubuntu22.04@sha256:94c1577b2cd9dd6c0312dc04dff9cb2fdce2b268018abc3d7c2dbcacf1155000 AS prod-cuda
|
|
|
|
|
|
|
|
RUN apt-get update && \
|
|
|
|
apt-get install --no-install-recommends -yqq libcudnn9-cuda-12 && \
|
|
|
|
apt-get clean && \
|
|
|
|
rm -rf /var/lib/apt/lists/*
|
2024-01-11 17:26:46 +00:00
|
|
|
|
2024-01-21 23:22:39 +00: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 17:26:46 +00:00
|
|
|
|
2024-08-05 12:07:28 +00:00
|
|
|
FROM prod-cpu AS prod-armnn
|
2023-07-21 14:20:04 +00:00
|
|
|
|
2024-01-21 23:22:39 +00:00
|
|
|
ENV LD_LIBRARY_PATH=/opt/armnn
|
|
|
|
|
2024-07-20 19:59:27 +00:00
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends ocl-icd-libopencl1 mesa-opencl-icd libgomp1 && \
|
2024-01-11 17:26:46 +00:00
|
|
|
rm -rf /var/lib/apt/lists/* && \
|
|
|
|
mkdir --parents /etc/OpenCL/vendors && \
|
2024-02-12 18:29:55 +00:00
|
|
|
echo "/usr/lib/libmali.so" > /etc/OpenCL/vendors/mali.icd && \
|
|
|
|
mkdir /opt/armnn
|
2024-01-21 23:22:39 +00:00
|
|
|
|
|
|
|
COPY --from=builder-armnn \
|
2024-03-16 04:04:45 +00: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-21 23:22:39 +00:00
|
|
|
|
2024-08-05 12:07:28 +00:00
|
|
|
FROM prod-${DEVICE} AS prod
|
2024-07-21 23:30:24 +00:00
|
|
|
ARG DEVICE
|
2024-01-21 23:22:39 +00:00
|
|
|
|
|
|
|
RUN apt-get update && \
|
2024-07-21 23:30:24 +00: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-21 23:22:39 +00:00
|
|
|
rm -rf /var/lib/apt/lists/*
|
2024-01-11 17:26:46 +00:00
|
|
|
|
2023-06-05 14:40:48 +00:00
|
|
|
WORKDIR /usr/src/app
|
2024-05-17 17:30:05 +00:00
|
|
|
ENV TRANSFORMERS_CACHE=/cache \
|
2024-03-16 04:04:45 +00:00
|
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
|
|
|
PYTHONUNBUFFERED=1 \
|
|
|
|
PATH="/opt/venv/bin:$PATH" \
|
|
|
|
PYTHONPATH=/usr/src \
|
|
|
|
DEVICE=${DEVICE}
|
2023-03-01 17:48:35 +00:00
|
|
|
|
2023-12-17 02:30:29 +00: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 14:40:48 +00:00
|
|
|
COPY --from=builder /opt/venv /opt/venv
|
2024-01-11 17:26:46 +00:00
|
|
|
COPY ann/ann.py /usr/src/ann/ann.py
|
2024-10-07 21:37:45 +00:00
|
|
|
COPY start.sh log_conf.json gunicorn_conf.py ./
|
2023-06-05 14:40:48 +00:00
|
|
|
COPY app .
|
2023-07-21 14:20:04 +00:00
|
|
|
ENTRYPOINT ["tini", "--"]
|
2023-08-31 23:30:53 +00:00
|
|
|
CMD ["./start.sh"]
|
2024-05-22 16:54:29 +00:00
|
|
|
|
|
|
|
HEALTHCHECK CMD python3 healthcheck.py
|