From 620b945975c9d6086cfe8787a9ada2d8faa4433b Mon Sep 17 00:00:00 2001 From: Gabriela Cervantes Date: Thu, 13 Jul 2023 21:31:10 +0000 Subject: [PATCH] metrics: Add Tensorflow Mobilenet documentation This PR adds the Tensorflow mobilinet documentation for the machine learning README. Signed-off-by: Gabriela Cervantes --- tests/metrics/machine_learning/README.md | 17 +++++++++++++++++ .../tensorflow_mobilenet_benchmark.sh | 14 +++++++------- .../tensorflow_mobilenet_dockerfile/Dockerfile | 8 ++++---- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/tests/metrics/machine_learning/README.md b/tests/metrics/machine_learning/README.md index 8c62b1566f..f797a38c30 100644 --- a/tests/metrics/machine_learning/README.md +++ b/tests/metrics/machine_learning/README.md @@ -27,3 +27,20 @@ Individual tests can be run by hand, for example: $ cd metrics/machine_learning $ ./tensorflow.sh 40 100 ``` +# Kata Containers Tensorflow `MobileNet` Metrics + +`MobileNets` are small, low-latency, low-power models parameterized to meet the resource +constraints of a variety of use cases. They can be built upon for classification, detection, +embeddings and segmentation similar to how other popular large scale models, such as Inception, are used. +`MobileNets` can be run efficiently on mobile devices with `Tensorflow` Lite. + +Kata Containers provides a test for running `MobileNet V1` inference using Intel-Optimized `Tensorflow`. + +## Running the `Tensorflow` `MobileNet` test +Individual test can be run by hand, for example: + +``` +$ cd metrics/machine_learning +$ ./tensorflow_mobilenet_benchmark.sh 25 60 +``` + diff --git a/tests/metrics/machine_learning/tensorflow_mobilenet_benchmark.sh b/tests/metrics/machine_learning/tensorflow_mobilenet_benchmark.sh index 6bc7598d83..63b42c1e7f 100755 --- a/tests/metrics/machine_learning/tensorflow_mobilenet_benchmark.sh +++ b/tests/metrics/machine_learning/tensorflow_mobilenet_benchmark.sh @@ -4,7 +4,7 @@ # # SPDX-License-Identifier: Apache-2.0 -set -o pipefial +set -o pipefail # General env SCRIPT_PATH=$(dirname "$(readlink -f "$0")") @@ -22,7 +22,7 @@ TESTDIR="${TESTDIR:-/testdir}" dst_dir="/host" src_dir=$(mktemp --tmpdir -d tensorflowai.XXXXXXXXXX) MOUNT_OPTIONS="type=bind,src=$src_dir,dst=$dst_dir,options=rbind:ro" -start_script="mobilnet_start.sh" +start_script="mobilenet_start.sh" # CMD points to the script that starts the workload CMD="$dst_dir/$start_script" guest_trigger_file="$dst_dir/$trigger_file" @@ -100,13 +100,13 @@ function mobilenet_test() { sudo -E "${CTR_EXE}" t exec --exec-id "$(random_name)" "${i}" sh -c "${CMD_RESULTS}" >> "${tensorflow_file}" done - local mobilnet_results=$(cat "${tensorflow_file}" | sed 's/.$//') - local average_mobilnet=$(echo "${mobilnet_results}" | sed 's/.$//' | sed "s/,/+/g;s/.*/(&)\/$NUM_CONTAINERS/g" | bc -l) + local mobilenet_results=$(cat "${tensorflow_file}" | sed 's/.$//') + local average_mobilenet=$(echo "${mobilenet_results}" | sed 's/.$//' | sed "s/,/+/g;s/.*/(&)\/$NUM_CONTAINERS/g" | bc -l) local json="$(cat << EOF { - "Mobilnet": { - "Result": "${mobilnet_results}", - "Average": "${average_mobilnet}", + "Mobilenet": { + "Result": "${mobilenet_results}", + "Average": "${average_mobilenet}", "Units": "images/s" } } diff --git a/tests/metrics/machine_learning/tensorflow_mobilenet_dockerfile/Dockerfile b/tests/metrics/machine_learning/tensorflow_mobilenet_dockerfile/Dockerfile index a7672bd7fe..fd1bd31eca 100644 --- a/tests/metrics/machine_learning/tensorflow_mobilenet_dockerfile/Dockerfile +++ b/tests/metrics/machine_learning/tensorflow_mobilenet_dockerfile/Dockerfile @@ -11,11 +11,11 @@ ENV DEBIAN_FRONTEND=noninteractive LABEL DOCKERFILE_VERSION="1.0" RUN apt-get update && \ - apt-get install -y --no-install-recommends wget nano curl build-essential git && \ + apt-get install -y wget nano curl build-essential git && \ apt-get install -y python3.8 python3-pip && \ - pip install intel-tensorflow-avx512==2.8.0 && \ - pip install protobuf==3.20.* && \ - wget https://storage.googleapis.com/intel-optimized-tensorflow/models/v1_8/mobilenet_v1_1.0_224_frozen.pb && \ + pip install --no-cache-dir intel-tensorflow-avx512==2.8.0 && \ + pip install --no-cache-dir protobuf==3.20.* && \ + wget -q https://storage.googleapis.com/intel-optimized-tensorflow/models/v1_8/mobilenet_v1_1.0_224_frozen.pb && \ git clone https://github.com/IntelAI/models.git CMD ["/bin/bash"]