Skip to content

Commit 1f39a94

Browse files
authored
Add warmup run and multi instance runs with numactl (#2591)
1 parent a29573a commit 1f39a94

File tree

4 files changed

+80
-3
lines changed

4 files changed

+80
-3
lines changed

Diff for: models/recommendation/tensorflow/wide_deep/inference/wide_deep_inference.py

+3
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,11 @@ def evaluate_model(self):
126126
[self.x_test_categ[:, i] for i in range(self.x_test_categ.shape[1])] +\
127127
[self.x_test_categ_poly]
128128
loaded_model = load_model(os.path.join(self.args.pretrained_model, 'wide_and_deep.h5'))
129+
# Warmup run
130+
result = loaded_model.predict(input_data,batch_size=self.args.batch_size)
129131
test_file = os.path.join(self.args.data_location, 'adult.test')
130132
num_records = sum(1 for line in open(test_file))
133+
# Benchmark run
131134
inference_start = time.time()
132135
result = loaded_model.predict(input_data,batch_size=self.args.batch_size)
133136
main_end = time.time()

Diff for: models_v2/tensorflow/wide_deep/inference/cpu/accuracy.sh

+29-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#
1717

1818
MODEL_DIR=${MODEL_DIR-$PWD}
19+
MODE="inference"
1920

2021
# echo 'MODEL_DIR='$MODEL_DIR
2122
#echo 'OUTPUT_DIR='$OUTPUT_DIR
@@ -62,14 +63,41 @@ if [[ -z "${BATCH_SIZE}" ]]; then
6263
echo "Running with default batch size of ${BATCH_SIZE}"
6364
fi
6465

66+
# If cores per instance env is not mentioned, then the workload will run with the default value.
67+
if [ -z "${CORES_PER_INSTANCE}" ]; then
68+
# Get number of cores per instance
69+
CORES_PER_SOCKET=`lscpu | grep 'Core(s) per socket' | awk '{print $4}'`
70+
SOCKETS=`lscpu | grep Socket | awk '{print $2}'`
71+
NUMAS=`lscpu | grep 'NUMA node(s)' | awk '{print $3}'`
72+
CORES_PER_INSTANCE=`expr $CORES_PER_SOCKET \* $SOCKETS / $NUMAS`
73+
74+
echo "CORES_PER_SOCKET: $CORES_PER_SOCKET"
75+
echo "SOCKETS: $SOCKETS"
76+
echo "NUMAS: $NUMAS"
77+
echo "CORES_PER_INSTANCE: $CORES_PER_INSTANCE"
78+
fi
79+
6580
source "$MODEL_DIR/models_v2/common/utils.sh"
6681
_command python ${MODEL_DIR}/benchmarks/launch_benchmark.py \
6782
--framework tensorflow \
6883
--precision ${PRECISION} \
69-
--mode inference \
84+
--mode ${MODE} \
7085
--model-name wide_deep \
7186
--batch-size ${BATCH_SIZE} \
7287
--data-location ${DATASET_DIR} \
7388
--output-dir ${OUTPUT_DIR} \
7489
--accuracy-only \
90+
--num-intra-threads=${CORES_PER_INSTANCE} \
91+
--num-inter-threads=1 \
92+
--numa-cores-per-instance=${CORES_PER_INSTANCE} \
7593
$@
94+
95+
if [[ $? == 0 ]]; then
96+
cat ${OUTPUT_DIR}/wide_deep_${PRECISION}_${MODE}_bs${BATCH_SIZE}_cores*_all_instances.log | grep 'Test Accuracy: ' | sed -e s"/.*: //"
97+
echo "Test Accuracy:"
98+
grep 'Test Accuracy: ' ${OUTPUT_DIR}/wide_deep_${PRECISION}_${MODE}_bs${BATCH_SIZE}_cores*_all_instances.log | awk -F' ' '{sum+=$3; count+=1; print $3;} END{print sum/count} '
99+
exit 0
100+
else
101+
exit 1
102+
fi
103+

Diff for: models_v2/tensorflow/wide_deep/inference/cpu/inference_batch.sh

+27-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#
1717

1818
MODEL_DIR=${MODEL_DIR-$PWD}
19+
MODE="inference"
1920

2021
# echo 'MODEL_DIR='$MODEL_DIR
2122
#echo 'OUTPUT_DIR='$OUTPUT_DIR
@@ -61,14 +62,39 @@ if [[ -z "${BATCH_SIZE}" ]]; then
6162
BATCH_SIZE="1024"
6263
echo "Running with default batch size of ${BATCH_SIZE}"
6364
fi
65+
# If cores per instance env is not mentioned, then the workload will run with the default value.
66+
if [ -z "${CORES_PER_INSTANCE}" ]; then
67+
# Get number of cores per instance
68+
CORES_PER_SOCKET=`lscpu | grep 'Core(s) per socket' | awk '{print $4}'`
69+
SOCKETS=`lscpu | grep Socket | awk '{print $2}'`
70+
NUMAS=`lscpu | grep 'NUMA node(s)' | awk '{print $3}'`
71+
CORES_PER_INSTANCE=`expr $CORES_PER_SOCKET \* $SOCKETS / $NUMAS`
72+
73+
echo "CORES_PER_SOCKET: $CORES_PER_SOCKET"
74+
echo "SOCKETS: $SOCKETS"
75+
echo "NUMAS: $NUMAS"
76+
echo "CORES_PER_INSTANCE: $CORES_PER_INSTANCE"
77+
fi
6478

6579
source "$MODEL_DIR/models_v2/common/utils.sh"
6680
_command python ${MODEL_DIR}/benchmarks/launch_benchmark.py \
6781
--framework tensorflow \
6882
--precision ${PRECISION} \
69-
--mode inference \
83+
--mode ${MODE} \
7084
--model-name wide_deep \
7185
--batch-size ${BATCH_SIZE} \
7286
--data-location ${DATASET_DIR} \
7387
--output-dir ${OUTPUT_DIR} \
88+
--num-intra-threads=${CORES_PER_INSTANCE} \
89+
--num-inter-threads=1 \
90+
--numa-cores-per-instance=${CORES_PER_INSTANCE} \
7491
$@
92+
93+
if [[ $? == 0 ]]; then
94+
cat ${OUTPUT_DIR}/wide_deep_${PRECISION}_${MODE}_bs${BATCH_SIZE}_cores*_all_instances.log | grep 'Throughput is: ' | sed -e s"/.*: //"
95+
echo "Throughput summary:"
96+
grep 'Throughput is: ' ${OUTPUT_DIR}/wide_deep_${PRECISION}_${MODE}_bs${BATCH_SIZE}_cores*_all_instances.log | awk -F' ' '{sum+=$3; print $3;} END{print sum} '
97+
exit 0
98+
else
99+
exit 1
100+
fi

Diff for: models_v2/tensorflow/wide_deep/inference/cpu/inference_online.sh

+21-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#
1717

1818
MODEL_DIR=${MODEL_DIR-$PWD}
19+
MODE="inference"
1920

2021
# echo 'MODEL_DIR='$MODEL_DIR
2122
#echo 'OUTPUT_DIR='$OUTPUT_DIR
@@ -62,13 +63,32 @@ if [[ -z "${BATCH_SIZE}" ]]; then
6263
echo "Running with default batch size of ${BATCH_SIZE}"
6364
fi
6465

66+
# If cores per instance env is not mentioned, then the workload will run with the default value.
67+
if [ -z "${CORES_PER_INSTANCE}" ]; then
68+
CORES_PER_INSTANCE=4
69+
else
70+
CORES_PER_INSTANCE=${CORES_PER_INSTANCE}
71+
fi
72+
6573
source "$MODEL_DIR/models_v2/common/utils.sh"
6674
_command python ${MODEL_DIR}/benchmarks/launch_benchmark.py \
6775
--framework tensorflow \
6876
--precision ${PRECISION} \
69-
--mode inference \
77+
--mode ${MODE} \
7078
--model-name wide_deep \
7179
--batch-size ${BATCH_SIZE} \
7280
--data-location ${DATASET_DIR} \
7381
--output-dir ${OUTPUT_DIR} \
82+
--num-intra-threads=${CORES_PER_INSTANCE} \
83+
--num-inter-threads=1 \
84+
--numa-cores-per-instance=${CORES_PER_INSTANCE} \
7485
$@
86+
87+
if [[ $? == 0 ]]; then
88+
cat ${OUTPUT_DIR}/wide_deep_${PRECISION}_${MODE}_bs${BATCH_SIZE}_cores*_all_instances.log | grep 'Throughput is:' | sed -e s"/.*: //"
89+
echo "Throughput summary:"
90+
grep 'Throughput is:' ${OUTPUT_DIR}/wide_deep_${PRECISION}_${MODE}_bs${BATCH_SIZE}_cores*_all_instances.log | awk -F' ' '{sum+=$3;} END{print sum} '
91+
exit 0
92+
else
93+
exit 1
94+
fi

0 commit comments

Comments
 (0)