-
-
Notifications
You must be signed in to change notification settings - Fork 62
/
Dockerfile
75 lines (50 loc) · 2.27 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
# syntax=docker/dockerfile:1.4
FROM rust:1.79.0-bookworm as builder
ARG TARGETPLATFORM
ARG ONNXRUNTIME_VERSION
ARG GIT_V_TAG
ARG PROFILE=release
ARG FEATURES
RUN apt-get update && apt-get install -y llvm-dev libclang-dev clang cmake binutils
WORKDIR /usr/src/edge-runtime
COPY . .
RUN --mount=type=cache,target=/usr/local/cargo/registry,id=${TARGETPLATFORM} --mount=type=cache,target=/usr/src/edge-runtime/target,id=${TARGETPLATFORM} \
GIT_V_TAG=${GIT_V_TAG} cargo build --profile ${PROFILE} --features "${FEATURES}" && \
mv /usr/src/edge-runtime/target/${PROFILE}/edge-runtime /root
RUN objcopy --compress-debug-sections \
--only-keep-debug \
/root/edge-runtime \
/root/edge-runtime.debug
RUN objcopy --strip-debug \
--add-gnu-debuglink=/root/edge-runtime.debug \
/root/edge-runtime
# Application runtime without ONNX
FROM debian:bookworm-slim as edge-runtime-base
RUN apt-get update && apt-get install -y libssl-dev && rm -rf /var/lib/apt/lists/*
RUN apt-get remove -y perl && apt-get autoremove -y
COPY --from=builder /root/edge-runtime /usr/local/bin/edge-runtime
COPY --from=builder /root/edge-runtime.debug /usr/local/bin/edge-runtime.debug
# ONNX Runtime provider
# Application runtime with ONNX
FROM builder as ort
RUN ./scripts/install_onnx.sh $ONNXRUNTIME_VERSION $TARGETPLATFORM /root/onnxruntime
# ONNX Runtime CUDA provider
# Application runtime with ONNX CUDA
FROM builder as ort-cuda
RUN ./scripts/install_onnx.sh $ONNXRUNTIME_VERSION $TARGETPLATFORM /root/onnxruntime --gpu
FROM builder as preload-models
RUN ./scripts/download_models.sh
# With CUDA
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 as edge-runtime-cuda
COPY --from=edge-runtime-base /usr/local/bin/edge-runtime /usr/local/bin/edge-runtime
COPY --from=builder /root/edge-runtime.debug /usr/local/bin/edge-runtime.debug
COPY --from=ort-cuda /root/onnxruntime/lib/libonnxruntime.so* /usr/lib
COPY --from=preload-models /usr/src/edge-runtime/models /etc/sb_ai/models
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
ENTRYPOINT ["edge-runtime"]
# Base
FROM edge-runtime-base as edge-runtime
COPY --from=ort /root/onnxruntime/lib/libonnxruntime.so* /usr/lib
COPY --from=preload-models /usr/src/edge-runtime/models /etc/sb_ai/models
ENTRYPOINT ["edge-runtime"]