Skip to content

Commit 7522f1e

Browse files
committed
Updated process for tensorflow 2.14 and simplified configs
1 parent eb4d0bd commit 7522f1e

File tree

5 files changed

+35
-62
lines changed

5 files changed

+35
-62
lines changed

Dockerfile.aarch64

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM arm64v8/ubuntu:20.04 as base
1+
FROM debian:bookworm as base
22
ENV DEBIAN_FRONTEND=noninteractive
33
# See http://bugs.python.org/issue19846
44
ENV LANG C.UTF-8
@@ -10,33 +10,14 @@ ARG DEBIAN_FRONTEND=noninteractive
1010
RUN apt-get update && apt-get install -y --no-install-recommends \
1111
python3 \
1212
python3-pip \
13-
python3-dev \
14-
build-essential \
15-
protobuf-compiler \
16-
wget \
17-
curl \
18-
git \
19-
gpg-agent \
20-
gnupg \
21-
libgl1 \
22-
libglib2.0-0 \
23-
unzip \
24-
libstdc++6 && \
13+
python3-setuptools \
14+
git && \
2515
apt-get clean && \
2616
rm -rf /var/lib/apt/lists/* && \
2717
ln -s $(which python3) /usr/local/bin/python
2818

29-
# Update pip/setuptools
30-
RUN python3 -m pip --no-cache-dir install --upgrade \
31-
pip \
32-
setuptools
33-
3419
# Install dependancies for Tensorflow
35-
RUN python3 -m pip install --no-cache-dir https://github.com/snowzach/tensorflow-multiarch/releases/download/v2.7.0/tensorflow_io_gcs_filesystem-0.23.1-cp38-cp38-linux_aarch64.whl
36-
RUN python3 -m pip install --no-cache-dir https://github.com/snowzach/tensorflow-multiarch/releases/download/v2.7.0/tensorflow_io-0.23.1-cp38-cp38-linux_aarch64.whl
37-
38-
# Install Tensorflow
39-
RUN python3 -m pip install --no-cache-dir https://github.com/snowzach/tensorflow-multiarch/releases/download/v2.7.0/tensorflow-2.7.0-cp38-none-linux_aarch64.whl
40-
41-
ADD https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/tools/dockerfiles/bashrc /etc/bash.bashrc
42-
RUN chmod a+rwx /etc/bash.bashrc
20+
RUN python3 -m pip install --no-cache-dir --break-system-packages \
21+
protobuf==3.20.3 \
22+
tensorflow-io==0.35.0 \
23+
tensorflow==2.14.0

Dockerfile.amd64-noavx

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:20.04 as base
1+
FROM debian:bookworm as base
22
ENV DEBIAN_FRONTEND=noninteractive
33
# See http://bugs.python.org/issue19846
44
ENV LANG C.UTF-8
@@ -9,21 +9,14 @@ ARG DEBIAN_FRONTEND=noninteractive
99
# Install apt dependencies
1010
RUN apt-get update && apt-get install -y --no-install-recommends \
1111
python3 \
12-
python3-pip && \
12+
python3-pip \
13+
python3-setuptools \
14+
git && \
1315
apt-get clean && \
1416
rm -rf /var/lib/apt/lists/* && \
1517
ln -s $(which python3) /usr/local/bin/python
1618

17-
# Update pip/setuptools
18-
RUN python3 -m pip --no-cache-dir install --upgrade \
19-
pip \
20-
setuptools
21-
2219
# Install Tensorflow NOAVX and Deps
23-
RUN python3 -m pip install --no-cache-dir \
24-
https://github.com/snowzach/tensorflow-multiarch/releases/download/v2.7.0/tensorflow_io_gcs_filesystem-0.23.1+noavx-cp38-cp38-linux_x86_64.whl \
25-
https://github.com/snowzach/tensorflow-multiarch/releases/download/v2.7.0/tensorflow_io-0.23.1+noavx-cp38-cp38-linux_x86_64.whl \
26-
https://github.com/snowzach/tensorflow-multiarch/releases/download/v2.7.0/tensorflow-2.7.0+noavx-cp38-cp38-linux_x86_64.whl
20+
RUN python3 -m pip install --no-cache-dir --break-system-packages \
21+
https://github.com/snowzach/tensorflow-multiarch/releases/download/v2.14.0/tensorflow-2.14.0-cp311-cp311-linux_x86_64.whl
2722

28-
ADD https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/tools/dockerfiles/bashrc /etc/bash.bashrc
29-
RUN chmod a+rwx /etc/bash.bashrc

Dockerfile.armv7l

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,3 @@ RUN python3 -m pip install --no-cache-dir https://github.com/snowzach/tensorflow
4747
# Install Tensorflow
4848
RUN python3 -m pip install --no-cache-dir https://github.com/snowzach/tensorflow-multiarch/releases/download/v2.7.0/tensorflow-2.7.0-cp38-none-linux_armv7l.whl
4949

50-
ADD https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/tools/dockerfiles/bashrc /etc/bash.bashrc
51-
RUN chmod a+rwx /etc/bash.bashrc

README.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This is my attempt to build a recent Tensorflow wheel and Docker image compatible with multiple architectures and processors.
44

5-
It's currently using Tensorflow v2.7.0
5+
It's currently using Tensorflow v2.14.0
66

77
It supports the following architectures:
88
- ARM32
@@ -16,7 +16,7 @@ The docker images are `docker.io/snowzach/tensorflow-multiarch` [here](https://h
1616
The default/latest docker images includes arm32, arm64 and amd64-noavx
1717

1818
## Compiling Tensorflow Wheel
19-
I checked out the Tensorflow source at version 2.7.0 and I had to edit the file `tensorflow/tools/ci_build/pi/build_raspberry_pi.sh` and insert on line 99 to add an ARMHF target.
19+
I checked out the Tensorflow source at version 2.14.0 and I had to edit the file `tensorflow/tools/ci_build/pi/build_raspberry_pi.sh` and insert on line 99 to add an ARMHF target.
2020
```
2121
elif [[ $1 == "ARMHF" ]]; then
2222
PI_COPTS="--config=elinux_armhf
@@ -35,7 +35,7 @@ $ tensorflow/tools/ci_build/ci_build.sh PI-PYTHON38 \
3535
```
3636
After running the command there was working python whl and library in the `output-artifacts` directory.
3737

38-
I renamed the armhf output wheel from `tensorflow-2.7.0-cp38-none-linux_armhf.whl` to `tensorflow-2.7.0-cp38-none-linux_armv7l.whl` to ensure it matched the hardware architecture and would be installed by python.
38+
I renamed the armhf output wheel from `tensorflow-2.14.0-cp38-none-linux_armhf.whl` to `tensorflow-2.14.0-cp38-none-linux_armv7l.whl` to ensure it matched the hardware architecture and would be installed by python.
3939

4040
# Tensorflow IO
4141
Tensorflow IO is required in order to install the Tensorflow wheel. There seems to be a chicken-egg problem
@@ -50,7 +50,7 @@ $ git clone https://github.com/tensorflow/io.git
5050
$ cd io
5151
$ git checkout v0.23.1
5252
$ python3 setup.py install # Install just the python code
53-
$ python3 -m pip install tensorflow-2.7.0-cp38-none-linux_<arch>.whl # Install tensorflow wheel
53+
$ python3 -m pip install tensorflow-2.14.0-cp38-none-linux_<arch>.whl # Install tensorflow wheel
5454
```
5555

5656
From there I compiled Tensorflow IO with
@@ -74,19 +74,18 @@ I build them with docker buildx with these commands:
7474
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
7575
7676
# Build the docker images
77-
docker buildx build --push --platform linux/arm/v7 -f Dockerfile.armv7l --tag docker.io/snowzach/tensorflow-multiarch:2.7.0-armv7l .
78-
docker buildx build --push --platform linux/arm64/v8 -f Dockerfile.aarch64 --tag docker.io/snowzach/tensorflow-multiarch:2.7.0-aarch64 .
79-
docker build -f Dockerfile.amd64-noavx --tag docker.io/snowzach/tensorflow-multiarch:2.7.0-amd64-noavx .
80-
docker push docker.io/snowzach/tensorflow-multiarch:2.7.0-amd64-noavx
77+
docker buildx build --push --platform linux/arm/v7 -f Dockerfile.armv7l --tag docker.io/snowzach/tensorflow-multiarch:2.14.0-armv7l .
78+
docker buildx build --push --platform linux/arm64/v8 -f Dockerfile.aarch64 --tag docker.io/snowzach/tensorflow-multiarch:2.14.0-aarch64 .
79+
docker buildx build --push --platform linux/amd64 -f Dockerfile.amd64-noavx --tag docker.io/snowzach/tensorflow-multiarch:2.14.0-amd64-noavx .
8180
82-
# Tag the releases as 2.7.0
83-
docker manifest push --purge docker.io/snowzach/tensorflow-multiarch:2.7.0
84-
docker manifest create docker.io/snowzach/tensorflow-multiarch:2.7.0 docker.io/snowzach/tensorflow-multiarch:2.7.0-armv7l docker.io/snowzach/tensorflow-multiarch:2.7.0-aarch64 docker.io/snowzach/tensorflow-multiarch:2.7.0-amd64-noavx
85-
docker manifest push docker.io/snowzach/tensorflow-multiarch:2.7.0
81+
# Tag the releases as 2.14.0
82+
docker manifest push --purge docker.io/snowzach/tensorflow-multiarch:2.14.0
83+
docker manifest create docker.io/snowzach/tensorflow-multiarch:2.14.0 docker.io/snowzach/tensorflow-multiarch:2.14.0-armv7l docker.io/snowzach/tensorflow-multiarch:2.14.0-aarch64 docker.io/snowzach/tensorflow-multiarch:2.14.0-amd64-noavx
84+
docker manifest push docker.io/snowzach/tensorflow-multiarch:2.14.0
8685
8786
# Tag the releases as latest
8887
docker manifest push --purge docker.io/snowzach/tensorflow-multiarch:latest
89-
docker manifest create docker.io/snowzach/tensorflow-multiarch:latest docker.io/snowzach/tensorflow-multiarch:2.7.0-armv7l docker.io/snowzach/tensorflow-multiarch:2.7.0-aarch64 docker.io/snowzach/tensorflow-multiarch:2.7.0-amd64-noavx
88+
docker manifest create docker.io/snowzach/tensorflow-multiarch:latest docker.io/snowzach/tensorflow-multiarch:2.14.0-armv7l docker.io/snowzach/tensorflow-multiarch:2.14.0-aarch64 docker.io/snowzach/tensorflow-multiarch:2.14.0-amd64-noavx
9089
docker manifest push docker.io/snowzach/tensorflow-multiarch:latest
9190
9291
```

build-tensorflow-noavx.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
#!/bin/bash
2-
# docker run -it -v /data/git/video/doodsp:/doodsp ubuntu:20.04 /bin/bash
2+
# docker run -it -v /data/git/video/tensorflow-multiarch:/tensorflow-multiarch debian:bookworm /bin/bash
33
export DEBIAN_FRONTEND=noninteractive
4-
export LANG C.UTF-8
4+
export LANG=C.UTF-8
55

66
cd /tmp
77

88
apt-get update && apt-get install -y --no-install-recommends \
99
pkg-config zip zlib1g-dev unzip wget bash-completion git curl \
10-
build-essential patch g++ cmake ca-certificates \
10+
build-essential patch g++ clang cmake ca-certificates \
1111
python3 python3-dev python3-distutils python3-numpy python3-six \
12-
libc6-dev libstdc++6 libusb-1.0-0
12+
libc6-dev libstdc++6 libusb-1.0-0 patchelf llvm-16 clang-16
1313

14-
export PROTOC_VERSION="3.14.0"
15-
export BAZEL_VERSION="3.7.2"
16-
export TF_VERSION="v2.7.0"
14+
export PROTOC_VERSION="3.20.3"
15+
export BAZEL_VERSION="6.1.0"
16+
export TF_VERSION="v2.14.0"
17+
export TF_PYTHON_VERSION=3.11
1718

1819
# Install protoc
1920
wget https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip && \
@@ -35,6 +36,7 @@ export TF_NEED_GDR=0 TF_NEED_AWS=0 TF_NEED_GCP=0 TF_NEED_CUDA=0 TF_NEED_HDFS=0 T
3536
yes '' | ./configure
3637

3738
# Build
38-
export BAZEL_COPT_FLAGS="--local_ram_resources=HOST_RAM*.5 --local_cpu_resources=HOST_CPUS*.75 --copt=-O3 --copt=-fomit-frame-pointer --config=noaws --config=nohdfs"
39+
export BAZEL_COPT_FLAGS="--local_ram_resources=HOST_RAM*.5 --local_cpu_resources=HOST_CPUS*.75 --copt=-O3 --copt=-fomit-frame-pointer --copt=-march=core2 --config=noaws --config=nohdfs"
3940
export BAZEL_EXTRA_FLAGS="--host_linkopt=-lm"
4041
bazel build -c opt $BAZEL_COPT_FLAGS --verbose_failures $BAZEL_EXTRA_FLAGS //tensorflow/tools/pip_package:build_pip_package
42+
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

0 commit comments

Comments
 (0)