Last active
June 6, 2019 18:44
-
-
Save MattsonThieme/60e7eba13d6dc80f7d69c52bebae4d19 to your computer and use it in GitHub Desktop.
Intel TensorFlow CNN Benchmarking Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Copyright (c) 2019 Intel Corporation | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# | |
####### USAGE ######### | |
# bash intel_tf_cnn_benchmarks.sh <option> | |
# | |
# This script runs on the AWS DL AMI. It activates the tensorflow_p36 environment and executes the TF CNN Benchmark script. | |
# | |
# By default, this runs only InceptionV3 at batch size 128. Pass "all" in the <option> | |
# position to run all networks and batch sizes in the benchmarking suite. | |
# | |
# This script runs training with TensorFlow's CNN Benchmarks and summarizes throughput increases when | |
# using Intel optimized TensorFlow. | |
# Note: you may need to edit benchmarks/scripts/tf_cnn_benchmarks/datasets.py to | |
# import _pickle instead of Cpickle | |
# Set number of batches | |
num_batches=( 30 ) | |
# Check if "all" option was passed, set networks and batch sizes accordingly | |
option=$1 | |
if [ -z $option ] | |
then | |
networks=( inception3 ) | |
batch_sizes=( 128 ) | |
else | |
networks=( inception3 resnet50 resnet152 vgg16 ) | |
batch_sizes=( 32 64 128 ) | |
fi | |
# Check TF version so that we clone the right benchmarks | |
source activate tensorflow_p36 | |
export tfversion=$(python -c "import tensorflow as tf;print(tf.__version__)") | |
conda deactivate | |
arr=(${tfversion//./ }) # Parse version and release | |
export version=${arr[0]} | |
export release=${arr[1]} | |
# Clone benchmark scripts for appropriate TF version | |
git clone -b cnn_tf_v${version}.${release}_compatible https://github.com/tensorflow/benchmarks.git | |
cd benchmarks/scripts/tf_cnn_benchmarks | |
rm *.log # remove logs from any previous benchmark runs | |
## Run benchmark scripts in the Intel Optimized environment | |
source activate tensorflow_p36 | |
for network in "${networks[@]}" ; do | |
for bs in "${batch_sizes[@]}"; do | |
echo -e "\n\n #### Starting $network and batch size = $bs ####\n\n" | |
time python tf_cnn_benchmarks.py \ | |
--data_format NCHW \ | |
--data_name imagenet \ | |
--device cpu \ | |
--mkl=True \ | |
--model "$network" \ | |
--batch_size "$bs" \ | |
--num_batches "$num_batches" \ | |
2>&1 | tee net_"$network"_bs_"$bs"_optimized.log | |
done | |
done | |
conda deactivate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment