Skip to content

Commit 9693e5d

Browse files
nSircombeLukeIreland1JLouisKaplan-Arm
committed
Update to tensorflow-aarch64 and pytorch-aarch64 Docker builds
- Adds more verbose welcome message - Enables support for v8a targets Default TensorFlow build is now 'generic' which will now support a greater range of targets including A72 and Neoverse cores. - Updates TF build to use Compute Library 21.11 - Updates PyTorch build to use Compute Library 21.11 - Disables caching of ACL softmax primitives in TensorFlow Co-authored-by: Luke Ireland <[email protected]> Co-authored-by: Jonathan Louis Kaplan <[email protected]>
1 parent e9490ae commit 9693e5d

File tree

12 files changed

+215
-939
lines changed

12 files changed

+215
-939
lines changed

docker/pytorch-aarch64/Dockerfile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ RUN apt-get -y update && \
6666
libncursesw5-dev \
6767
libpng-dev \
6868
libreadline-dev \
69-
libssl-dev \
69+
libsox-fmt-all \
7070
libsqlite3-dev \
71+
libssl-dev \
7172
libxml2-dev \
7273
libxslt-dev \
7374
locales \
@@ -90,6 +91,7 @@ RUN apt-get -y update && \
9091
rsyslog \
9192
snapd \
9293
scons \
94+
sox \
9395
ssh \
9496
sudo \
9597
time \
@@ -143,7 +145,7 @@ ENV NP_MAKE="${njobs}" \
143145
ACL_ARCH="${acl_arch}"
144146

145147
# Key version numbers
146-
ENV ACL_VERSION="v21.08" \
148+
ENV ACL_VERSION="v21.11" \
147149
OPENBLAS_VERSION=0.3.10 \
148150
NINJA_VERSION=1.9.0
149151

@@ -345,6 +347,10 @@ RUN pip install --no-cache-dir tqdm
345347
RUN pip install --no-cache-dir boto3
346348
RUN pip install --no-cache-dir future onnx==1.8.1
347349
RUN pip install --no-cache-dir iopath
350+
RUN pip install --no-cache-dir sox
351+
RUN pip install --no-cache-dir unidecode
352+
RUN pip install --no-cache-dir inflect
353+
RUN pip install --no-cache-dir 'librosa==0.8.0'
348354

349355
# Copy examples
350356
ENV EXAMPLE_DIR=/home/$DOCKER_USER/examples

docker/pytorch-aarch64/examples/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,10 @@ In order to reduce the runtime, for the purposes of confirming that it runs as e
185185

186186
#### RNNT
187187

188-
The speech recognition RNNT benchmark ([original paper available here](https://arxiv.org/pdf/1811.06621.pdf)) generates character transcriptions from raw audio samples. It is not built by default due to the time requirements for building its dependencies, and the size of the dataset (over 1000 hours of audio).
188+
The speech recognition RNNT benchmark ([original paper available here](https://arxiv.org/pdf/1811.06621.pdf)) generates character transcriptions from raw audio samples. The data and model parameters are not included in the Docker image by default due to their size (~1GB), but can be downloaded easily using the shell scripts described below.
189189

190-
Three separate shell scripts for dependency build, model and data download, and running stages are generated for the built image using a patch file. These scripts can be found in `$HOME/examples/MLCommons/inference/speech_recognition/rnnt/` of the built image.
190+
Two shell scripts for model and data download, and running scenarios are generated for the built image using a patch file. These scripts can be found in `$HOME/examples/MLCommons/inference/speech_recognition/rnnt/` of the built image.
191191

192-
* `build-rnnt.sh` builds sox with flac support from source and installs the requisite Python packages
193192
* `download_dataset_model.sh` downloads the model and test dataset
194193
* `run.sh` runs the test, by default only the SingleStream scenario latency test
195194

docker/pytorch-aarch64/patches/mlcommons_rnnt.patch

Lines changed: 14 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
#
2323
# *******************************************************************************
2424
diff --git a/speech_recognition/rnnt/README.md b/speech_recognition/rnnt/README.md
25-
index 27fbabd..6be2742 100644
25+
index 27fbabd..2794bed 100644
2626
--- a/speech_recognition/rnnt/README.md
2727
+++ b/speech_recognition/rnnt/README.md
28-
@@ -4,18 +4,13 @@ character transcription, without an external language model.
28+
@@ -4,18 +4,12 @@ character transcription, without an external language model.
2929

3030
# 2. Directions
3131

@@ -41,7 +41,6 @@ index 27fbabd..6be2742 100644
4141
-
4242
-As you complete individual stages, you can set the variable "stage" to
4343
-a higher number for restarting from a later stage.
44-
+To build and install necessary dependencies, run `build-rnnt.sh`.
4544
+To download the dataset and model, run `download_dataset_model.sh`.
4645
+To run the model, use `run.sh`; this shell script runs the SingleStream
4746
+scenario by default if no others are specified. Use `run.sh --help` to
@@ -51,72 +50,19 @@ index 27fbabd..6be2742 100644
5150

5251
# 3. Dataset/Environment
5352
### Publication/Attribution
54-
@@ -113,4 +108,4 @@ The differences are as follows:
53+
@@ -113,4 +107,4 @@ The differences are as follows:
5554
### Quality metric
5655
7.452253714852645% Word Error Rate (WER) across all words in the output text of
5756
all samples less than 15 seconds in length in the dev-clean set, using a greedy
5857
-decoder and a fully FP32 model.
5958
\ No newline at end of file
6059
+decoder and a fully FP32 model.
61-
diff --git a/speech_recognition/rnnt/build-rnnt.sh b/speech_recognition/rnnt/build-rnnt.sh
62-
new file mode 100755
63-
index 0000000..c2563c3
64-
--- /dev/null
65-
+++ b/speech_recognition/rnnt/build-rnnt.sh
66-
@@ -0,0 +1,47 @@
67-
+#!/bin/bash
68-
+# *******************************************************************************
69-
+# Copyright 2021 Arm Limited and affiliates.
70-
+# SPDX-License-Identifier: Apache-2.0
71-
+#
72-
+# Licensed under the Apache License, Version 2.0 (the "License");
73-
+# you may not use this file except in compliance with the License.
74-
+# You may obtain a copy of the License at
75-
+#
76-
+# http://www.apache.org/licenses/LICENSE-2.0
77-
+#
78-
+# Unless required by applicable law or agreed to in writing, software
79-
+# distributed under the License is distributed on an "AS IS" BASIS,
80-
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
81-
+# See the License for the specific language governing permissions and
82-
+# limitations under the License.
83-
+# *******************************************************************************
84-
+set -euo pipefail
85-
+
86-
+base="$(dirname "${BASH_SOURCE[0]}")"
87-
+work_dir=$base/temp_work
88-
+local_data_dir=$work_dir/local_data
89-
+librispeech_download_dir=$local_data_dir/LibriSpeech
90-
+
91-
+mkdir -p $librispeech_download_dir
92-
+
93-
+install_dir=$base/third_party/install
94-
+mkdir -p $install_dir
95-
+install_dir=$(readlink -f $install_dir)
96-
+
97-
+# if venv not active, activate
98-
+if [[ $(python -c "import sys; print(sys.prefix)") != "/home/ubuntu/python3-venv" ]]; then
99-
+ source /home/ubuntu/python3-venv/bin/activate
100-
+fi
101-
+
102-
+# We need to convert .flac files to .wav files via sox. Not all sox installs have flac support, so we install from source.
103-
+wget https://ftp.osuosl.org/pub/xiph/releases/flac/flac-1.3.2.tar.xz -O third_party/flac-1.3.2.tar.xz
104-
+(cd third_party; tar xf flac-1.3.2.tar.xz; cd flac-1.3.2; CFLAGS="-I/home/ubuntu/inference/speech_recognition/rnnt/third_party/pybind/include"; ./configure --prefix=$install_dir && make && make install)
105-
+
106-
+wget https://sourceforge.net/projects/sox/files/sox/14.4.2/sox-14.4.2.tar.gz -O third_party/sox-14.4.2.tar.gz
107-
+(cd third_party; tar zxf sox-14.4.2.tar.gz; cd sox-14.4.2; LDFLAGS="-L${install_dir}/lib" CFLAGS="-I${install_dir}/include -I/home/ubuntu/inference/speech_recognition/rnnt/third_party/pybind/include" ./configure --prefix=$install_dir --with-flac && make && make install)
108-
+
109-
+(cd $(git rev-parse --show-toplevel)/loadgen; python setup.py install)
110-
+
111-
+pip install sox
112-
+pip install unidecode inflect
113-
+pip install 'librosa==0.8.0'
11460
diff --git a/speech_recognition/rnnt/download_dataset_model.sh b/speech_recognition/rnnt/download_dataset_model.sh
11561
new file mode 100755
116-
index 0000000..348cdb7
62+
index 0000000..8d4ac05
11763
--- /dev/null
11864
+++ b/speech_recognition/rnnt/download_dataset_model.sh
119-
@@ -0,0 +1,49 @@
65+
@@ -0,0 +1,46 @@
12066
+#!/bin/bash
12167
+# *******************************************************************************
12268
+# Copyright 2021 Arm Limited and affiliates.
@@ -141,16 +87,13 @@ index 0000000..348cdb7
14187
+local_data_dir=$work_dir/local_data
14288
+librispeech_download_dir=$local_data_dir/LibriSpeech
14389
+
144-
+install_dir=$base/third_party/install
145-
+install_dir=$(readlink -f $install_dir)
90+
+mkdir -p $librispeech_download_dir
14691
+
14792
+# if venv not active, activate
14893
+if [[ $(python -c "import sys; print(sys.prefix)") != "/home/ubuntu/python3-venv" ]]; then
14994
+ source /home/ubuntu/python3-venv/bin/activate
15095
+fi
15196
+
152-
+export PATH="$install_dir/bin/:$PATH"
153-
+
15497
+# stage 0: download model. Check checksum to skip?
15598
+wget https://zenodo.org/record/3662521/files/DistributedDataParallel_1576581068.9962234-epoch-100.pt?download=1 -O $work_dir/rnnt.pt
15699
+
@@ -194,10 +137,10 @@ index 9bbea9c..39e2121 100644
194137
- return torch.cat(seq, dim=2)[::self.factor, :, :], x_lens
195138
+ return rt, x_lens
196139
diff --git a/speech_recognition/rnnt/run.sh b/speech_recognition/rnnt/run.sh
197-
index 7538df9..c9ebe43 100755
140+
index 7538df9..d65a87c 100755
198141
--- a/speech_recognition/rnnt/run.sh
199142
+++ b/speech_recognition/rnnt/run.sh
200-
@@ -1,90 +1,114 @@
143+
@@ -1,90 +1,108 @@
201144
-#/bin/bash
202145
-
203146
+#!/bin/bash
@@ -339,9 +282,10 @@ index 7538df9..c9ebe43 100755
339282
- --input_dir $librispeech_download_dir/dev-clean \
340283
- --dest_dir $local_data_dir/dev-clean-wav \
341284
- --output_json $local_data_dir/dev-clean-wav.json
342-
-fi
343-
+install_dir=$base/third_party/install
344-
+install_dir=$(readlink -f $install_dir)
285+
+# if venv not active, activate
286+
+if [[ $(python -c "import sys; print(sys.prefix)") != "/home/ubuntu/python3-venv" ]]; then
287+
+ source /home/ubuntu/python3-venv/bin/activate
288+
fi
345289

346290
-if [[ $stage -le 3 ]]; then
347291
- for backend in pytorch; do
@@ -352,11 +296,7 @@ index 7538df9..c9ebe43 100755
352296
- log_dir+=_accuracy
353297
- fi
354298
- log_dir+=rerun
355-
+# if venv not active, activate
356-
+if [[ $(python -c "import sys; print(sys.prefix)") != "/home/ubuntu/python3-venv" ]]; then
357-
+ source /home/ubuntu/python3-venv/bin/activate
358-
+fi
359-
299+
-
360300
- python run.py --backend pytorch \
361301
- --dataset_dir $local_data_dir \
362302
- --manifest $local_data_dir/dev-clean-wav.json \
@@ -366,9 +306,7 @@ index 7538df9..c9ebe43 100755
366306
- --backend ${backend} \
367307
- --log_dir ${log_dir} \
368308
- ${accuracy} &
369-
+# make sox executable findable by the Python package
370-
+export PATH="$install_dir/bin/:$PATH"
371-
309+
-
372310
- done
373311
- done
374312
- done
Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
11

22
================================================================================
33
PyTorch for AArch64
4-
Built using:
5-
https://github.com/ARM-software/Tool-Solutions
6-
For more details, see:
7-
https://github.com/ARM-software/Tool-Solutions/blob/master/docker/pytorch-aarch64/README.md
84
================================================================================
5+
6+
Built using: https://github.com/ARM-software/Tool-Solutions
7+
For more details, see: https://git.io/JMESY
8+
9+
--
10+
11+
The default user's home (/home/ubuntu) contains:
12+
13+
- examples/ - a selection of inference examples and benchmarks:
14+
-- Vision, Natural Language Processing (NLP) and speech recognition
15+
inference examples
16+
-- MLCommons/ - sample inference benchmarks for Vision and NLP,
17+
see https://github.com/mlcommons/inference
18+
19+
For more details, and instructions on how to run the benchmarks see:
20+
examples/README.md (https://git.io/JMESs)
21+
22+
- python3-venv/ - the complete python environment including PyTorch.
23+
24+
- CK/ containing Collective Knowledge (https://cknowledge.org) repositories
25+
used to manange datasets for the MLCommons benchmarks.
26+
=================================================================================

docker/tensorflow-aarch64/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ ENV PATH=$PACKAGE_DIR/bazel:$PATH
294294

295295
# Build TensorFlow
296296
COPY patches/tf_acl.patch $PACKAGE_DIR/.
297+
COPY patches/tf_softmax.patch $PACKAGE_DIR/.
297298
COPY patches/mkldnn_acl.patch $PACKAGE_DIR/.
298299
COPY patches/compute_library.patch $PACKAGE_DIR/.
299300
COPY scripts/build-tensorflow-io-gcs-filesystem.sh $PACKAGE_DIR/.

docker/tensorflow-aarch64/build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ function print_usage_and_exit {
4040
echo " * tensorflow - build image including TensorFlow build and benchmarks installed (default)."
4141
echo " * full - build all images."
4242
echo " --build-target AArch64 CPU target:"
43-
echo " * native - optimize for the current host machine (default)."
43+
echo " * generic - portable build suitable for any ARMv8-A target (default)."
44+
echo " * native - optimize for the current host machine."
4445
echo " * neoverse-n1 - optimize for Neoverse-N1"
4546
echo " * thunderx2t99 - optimize for Marvell ThunderX2."
46-
echo " * generic - generate portable build suitable for any Armv8a target."
4747
echo " * custom - use custom settings defined in cpu_info.sh"
4848
echo " GCC provides support for additional target cpu's refer to the gcc manual for details."
4949
echo " --no-cache / --clean Pull a new base image and build without using any cached images."
@@ -85,7 +85,7 @@ nproc_build=
8585
bazel_mem=
8686
onednn=
8787
enable_onednn=0
88-
target="native"
88+
target="generic"
8989
clean_build=
9090
image_tag="latest"
9191

docker/tensorflow-aarch64/cpu_info.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,12 @@ function set_target {
115115
eigen_l3_cache="512*1024"
116116
;;
117117
generic )
118+
# A portable build, suitible for all v8.x-a targets
118119
cpu="generic"
119120
tune="generic"
120121
arch="armv8-a"
121122
blas_cpu="ARMV8"
122-
blas_ncores=
123+
blas_ncores=64
123124
eigen_l1_cache=
124125
eigen_l2_cache=
125126
eigen_l3_cache=

0 commit comments

Comments
 (0)