Skip to content

Commit c095fc2

Browse files
dmsuehirKarthik Vadla
authored andcommitted
Add args to customize warmup_steps and steps for resnet50, resnet101, and inceptionv3 int8 (#192)
1 parent 3049df0 commit c095fc2

File tree

6 files changed

+79
-58
lines changed

6 files changed

+79
-58
lines changed

benchmarks/common/tensorflow/start.sh

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,22 @@ function install_protoc() {
163163

164164
}
165165

166+
function add_steps_args() {
167+
# returns string with --steps and --warmup_steps, if there are values specified
168+
local steps_arg=""
169+
local warmup_steps_arg=""
170+
171+
if [ -n "${steps}" ]; then
172+
steps_arg="--steps=${steps}"
173+
fi
174+
175+
if [ -n "${warmup_steps}" ]; then
176+
warmup_steps_arg="--warmup-steps=${warmup_steps}"
177+
fi
178+
179+
echo "${steps_arg} ${warmup_steps_arg}"
180+
}
181+
166182
# DCGAN model
167183
function dcgan() {
168184
if [ ${PRECISION} == "fp32" ]; then
@@ -258,7 +274,7 @@ function inceptionv3() {
258274
input_width_arg="--input-width=${input_width}"
259275
fi
260276

261-
CMD="${CMD} ${input_height_arg} ${input_width_arg}"
277+
CMD="${CMD} ${input_height_arg} ${input_width_arg} $(add_steps_args)"
262278
PYTHONPATH=${PYTHONPATH} CMD=${CMD} run_model
263279

264280
elif [ ${PRECISION} == "fp32" ]; then
@@ -365,6 +381,7 @@ function resnet101() {
365381
fi
366382

367383
if [ ${PRECISION} == "int8" ]; then
384+
CMD="${CMD} $(add_steps_args)"
368385
PYTHONPATH=${PYTHONPATH} CMD=${CMD} run_model
369386
elif [ ${PRECISION} == "fp32" ]; then
370387
CMD="${CMD} --in-graph=${IN_GRAPH} --data-location=${DATASET_LOCATION}"
@@ -385,6 +402,8 @@ function resnet50() {
385402
echo "No Data directory specified, accuracy will not be calculated."
386403
exit 1
387404
fi
405+
406+
CMD="${CMD} $(add_steps_args)"
388407
PYTHONPATH=${PYTHONPATH} CMD=${CMD} run_model
389408

390409
elif [ ${PRECISION} == "fp32" ]; then

benchmarks/image_recognition/tensorflow/inceptionv3/README.md

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ python launch_benchmark.py \
107107
-- input_height=299 input_width=299
108108
```
109109

110+
When running performance benchmarking, it is optional to specify the
111+
number of `warmup_steps` and `steps` as extra args, as shown in the
112+
commands below. If these values are not specified, the script will
113+
default to use `warmup_steps=10` and `steps=50`.
114+
110115
For latency (using `--benchmark-only`, `--socket-id 0` and `--batch-size 1`):
111116

112117
```
@@ -121,7 +126,7 @@ python launch_benchmark.py \
121126
--docker-image tf_int8_docker_image \
122127
--in-graph /home/myuser/inceptionv3_int8_pretrained_model.pb \
123128
--data-location /home/myuser/datasets/ImageNet_TFRecords \
124-
-- input_height=299 input_width=299
129+
-- input_height=299 input_width=299 warmup_steps=50 steps=500
125130
```
126131

127132
For throughput (using `--benchmark-only`, `--socket-id 0` and `--batch-size 128`):
@@ -138,7 +143,7 @@ python launch_benchmark.py \
138143
--docker-image tf_int8_docker_image \
139144
--in-graph /home/myuser/inceptionv3_int8_pretrained_model.pb \
140145
--data-location /home/myuser/datasets/ImageNet_TFRecords \
141-
-- input_height=299 input_width=299
146+
-- input_height=299 input_width=299 warmup_steps=50 steps=500
142147
```
143148

144149
Note that the `--verbose` or `--output-dir` flag can be added to any of the above commands
@@ -162,35 +167,28 @@ Log location outside container: {--output-dir value}/benchmark_inceptionv3_infer
162167

163168
Example log tail when benchmarking for latency:
164169
```
165-
[Running warmup steps...]
166-
steps = 10, 56.8087550114 images/sec
167-
[Running benchmark steps...]
168-
steps = 10, 57.2046753318 images/sec
169-
steps = 20, 56.7181068289 images/sec
170-
steps = 30, 57.015714208 images/sec
171-
steps = 40, 57.4216088933 images/sec
172-
steps = 50, 57.491659242 images/sec
170+
...
171+
steps = 470, 53.7256017113 images/sec
172+
steps = 480, 52.5430812016 images/sec
173+
steps = 490, 52.9076139058 images/sec
174+
steps = 500, 53.5021876395 images/sec
173175
lscpu_path_cmd = command -v lscpu
174176
lscpu located here: /usr/bin/lscpu
175177
Ran inference with batch size 1
176-
Log location outside container: {--output-dir value}/benchmark_inceptionv3_inference_int8_20190104_185906.log
178+
Log location outside container: {--output-dir value}/benchmark_inceptionv3_inference_int8_20190223_194002.log
177179
```
178180

179181
Example log tail when benchmarking for throughput:
180182
```
181-
[Running warmup steps...]
182-
steps = 10, 341.225945255 images/sec
183-
[Running benchmark steps...]
184-
steps = 10, 340.304326771 images/sec
185-
steps = 20, 339.108777134 images/sec
186-
steps = 30, 337.139199124 images/sec
187-
steps = 40, 341.177805273 images/sec
188-
steps = 50, 338.634144926 images/sec
183+
...
184+
steps = 470, 370.435654276 images/sec
185+
steps = 480, 369.710160177 images/sec
186+
steps = 490, 369.083388904 images/sec
187+
steps = 500, 370.287978128 images/sec
189188
lscpu_path_cmd = command -v lscpu
190189
lscpu located here: /usr/bin/lscpu
191-
Executing command: numactl --cpunodebind=0 --membind=0 python /workspace/intelai_models/int8/benchmark.py --input_height=299 --input_width=299 --warmup_steps=10 --num_intra_threads=56 --num_inter_threads=2 --batch_size=128 --input_graph=/in_graph/inceptionv3_int8_pretrained_model.pb --steps=50
192190
Ran inference with batch size 128
193-
Log location outside container: {--output-dir value}/benchmark_inceptionv3_inference_int8_20190104_014141.log
191+
Log location outside container: {--output-dir value}/benchmark_inceptionv3_inference_int8_20190223_194314.log
194192
```
195193

196194
## FP32 Inference Instructions

benchmarks/image_recognition/tensorflow/resnet101/README.md

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ $ python launch_benchmark.py \
9191
--in-graph=/home/myuser/resnet101_int8_pretrained_model.pb
9292
```
9393

94+
When running performance benchmarking, it is optional to specify the
95+
number of `warmup_steps` and `steps` as extra args, as shown in the
96+
commands below. If these values are not specified, the script will
97+
default to use `warmup_steps=40` and `steps=100`.
98+
9499
For latency (using `--benchmark-only`, `--socket-id 0` and `--batch-size 1`):
95100

96101
```
@@ -103,7 +108,8 @@ python launch_benchmark.py \
103108
--batch-size 1 \
104109
--socket-id 0 \
105110
--docker-image tf_int8_docker_image \
106-
--in-graph=/home/myuser/resnet101_int8_pretrained_model.pb
111+
--in-graph=/home/myuser/resnet101_int8_pretrained_model.pb \
112+
-- warmup_steps=50 steps=500
107113
```
108114

109115
For throughput (using `--benchmark-only`, `--socket-id 0` and `--batch-size 128`):
@@ -118,7 +124,8 @@ python launch_benchmark.py \
118124
--batch-size 128 \
119125
--socket-id 0 \
120126
--docker-image tf_int8_docker_image \
121-
--in-graph=/home/myuser/resnet101_int8_pretrained_model.pb
127+
--in-graph=/home/myuser/resnet101_int8_pretrained_model.pb \
128+
-- warmup_steps=50 steps=500
122129
```
123130

124131
Note that the `--verbose` or `--output-dir` flag can be added to any of the above commands
@@ -142,37 +149,28 @@ Log location outside container: {--output-dir value}/benchmark_resnet101_inferen
142149

143150
Example log tail when benchmarking for latency:
144151
```
145-
[Running warmup steps...]
146-
steps = 10, 53.3022912987 images/sec
147-
steps = 20, 54.8999856019 images/sec
148-
steps = 30, 54.5288420286 images/sec
149-
steps = 40, 54.3775556506 images/sec
150-
[Running benchmark steps...]
151-
steps = 10, 537.185143822 images/sec
152-
steps = 20, 268.75073286 images/sec
153-
steps = 30, 179.033434653 images/sec
154-
steps = 40, 134.356211634 images/sec
155-
steps = 50, 107.403547389 images/sec
156-
steps = 60, 89.3812766404 images/sec
157-
steps = 70, 76.565932747 images/sec
158-
steps = 80, 67.0330362294 images/sec
159-
steps = 90, 59.6184242546 images/sec
160-
steps = 100, 53.6588898046 images/sec
152+
...
153+
steps = 470, 48.3195530058 images/sec
154+
steps = 480, 47.2792312364 images/sec
155+
steps = 490, 46.3175214744 images/sec
156+
steps = 500, 45.4044245083 images/sec
161157
lscpu_path_cmd = command -v lscpu
162158
lscpu located here: /usr/bin/lscpu
163159
Ran inference with batch size 1
164-
Log location outside container: {--output-dir value}/benchmark_resnet101_inference.log
160+
Log location outside container: {--output-dir value}/benchmark_resnet101_inference_int8_20190223_191406.log
165161
```
166162

167163
Example log tail when benchmarking for throughput:
168164
```
169-
steps = 80, 328.404413955 images/sec
170-
steps = 90, 291.945088967 images/sec
171-
steps = 100, 262.656894016 images/sec
165+
...
166+
steps = 470, 328.906266308 images/sec
167+
steps = 480, 322.0451309 images/sec
168+
steps = 490, 315.455582114 images/sec
169+
steps = 500, 309.142758646 images/sec
172170
lscpu_path_cmd = command -v lscpu
173171
lscpu located here: /usr/bin/lscpu
174172
Ran inference with batch size 128
175-
Log location outside container: {--output-dir value}/benchmark_resnet101_inference_int8_20190104_211412.log
173+
Log location outside container: {--output-dir value}/benchmark_resnet101_inference_int8_20190223_192438.log
176174
```
177175

178176
## FP32 Inference Instructions

benchmarks/image_recognition/tensorflow/resnet101/inference/int8/model_init.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ def parse_args(self):
5555
help="input width")
5656
parser.add_argument('--warmup-steps', dest='warmup_steps',
5757
help='number of warmup steps', type=int,
58-
default=10)
58+
default=40)
5959
parser.add_argument('--steps', dest='steps',
6060
help='number of steps', type=int,
61-
default=200)
61+
default=100)
6262
parser.add_argument('--input-layer', dest='input_layer',
6363
help='name of input layer', type=str,
6464
default=None)

benchmarks/image_recognition/tensorflow/resnet50/README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ Log location outside container: {--output-dir value}/benchmark_resnet50_inferenc
7979
* Evaluate the model performance: The ImageNet dataset is not needed in this case:
8080
Calculate the model throughput `images/sec`, the required parameters to run the inference script would include:
8181
the pre-trained `resnet50_int8_pretrained_model.pb` input graph file (from step
82-
2, the docker image (from step 3) and the `--benchmark-only` flag.
82+
2, the docker image (from step 3) and the `--benchmark-only` flag. It is
83+
optional to specify the number of `warmup_steps` and `steps` as extra
84+
args, as shown in the command below. If these values are not specified,
85+
the script will default to use `warmup_steps=10` and `steps=50`.
8386

8487
```
8588
$ cd /home/myuser/models/benchmarks
@@ -92,23 +95,21 @@ $ python launch_benchmark.py \
9295
--mode inference \
9396
--batch-size=128 \
9497
--benchmark-only \
95-
--docker-image docker_image
98+
--docker-image docker_image \
99+
-- warmup_steps=50 steps=500
96100
```
97101
The tail of the log output when the benchmarking completes should look
98102
something like this:
99103
```
100-
[Running warmup steps...]
101-
steps = 10, 460.862674539 images/sec
102-
[Running benchmark steps...]
103-
steps = 10, 461.002369109 images/sec
104-
steps = 20, 460.082656541 images/sec
105-
steps = 30, 464.707827579 images/sec
106-
steps = 40, 463.187506632 images/sec
107-
steps = 50, 462.725212176 images/sec
104+
...
105+
steps = 470, 460.113806562 images/sec
106+
steps = 480, 460.073982602 images/sec
107+
steps = 490, 463.289831148 images/sec
108+
steps = 500, 463.521427264 images/sec
108109
lscpu_path_cmd = command -v lscpu
109110
lscpu located here: /usr/bin/lscpu
110111
Ran inference with batch size 128
111-
Log location outside container: {--output-dir value}/benchmark_resnet50_inference_int8_20190104_213139.log
112+
Log location outside container: {--output-dir value}/benchmark_resnet50_inference_int8_20190223_180546.log
112113
```
113114

114115
Note that the `--verbose` or `--output-dir` flag can be added to any of the above commands

0 commit comments

Comments
 (0)