-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile.tflite
46 lines (34 loc) · 2.04 KB
/
Dockerfile.tflite
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
FROM debian:bullseye AS builder
LABEL org.opencontainers.image.description="Base docker image with Tensorflow lite for precise-go builds"
RUN apt-get update && \
apt-get -y install git build-essential curl ca-certificates && \
rm -rf /var/lib/apt/lists/*
ARG TENSORFLOW_VERSION=2.11.0
RUN git clone /~https://github.com/tensorflow/tensorflow.git /usr/src/tensorflow && \
cd /usr/src/tensorflow && \
git checkout v$TENSORFLOW_VERSION
RUN \
# Install bazel (https://docs.bazel.build/versions/master/install-ubuntu.html) \
mkdir -p /etc/apt/keyrings || true && \
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/bazel.gpg] http://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list && \
curl -fsSL https://bazel.build/bazel-release.pub.gpg | tee | gpg --dearmor | tee /etc/apt/keyrings/bazel.gpg > /dev/null && \
apt-get update && \
apt-get -y install bazel-5.4.0 && \
apt-get -y upgrade bazel-5.4.0 && \
ln -s /usr/bin/bazel-5.4.0 /usr/bin/bazel && \
# Unpack bazel for future use.
bazel version
RUN apt-get install -y python3 python3-pip && \
pip3 install numpy
RUN cd /usr/src/tensorflow && \
./configure && \
bazel build --config opt --config monolithic //tensorflow:install_headers //tensorflow/lite:libtensorflowlite.so //tensorflow/lite/c:libtensorflowlite_c.so && \
cp /usr/src/tensorflow/bazel-bin/tensorflow/lite/libtensorflowlite.so /usr/lib && \
cp /usr/src/tensorflow/bazel-bin/tensorflow/lite/c/libtensorflowlite_c.so /usr/lib && \
tar -C /usr/src/tensorflow/bazel-bin/tensorflow/include -zcvf /usr/include/tf-include.tar.gz . && \
cp -R /usr/src/tensorflow/bazel-bin/tensorflow/include/* /usr/include/
FROM debian:bullseye
# Multi-stage build because bazel creates a lot of excess items. We only need the include files and libraries.
COPY --from=builder /usr/include/tf-include.tar.gz /usr/include
RUN tar -C /usr/include -xvf /usr/include/tf-include.tar.gz
COPY --from=builder /usr/lib/libtensorflowlite.so /usr/lib/libtensorflowlite_c.so /usr/lib/