-
Notifications
You must be signed in to change notification settings - Fork 220
/
start.sh
2171 lines (1884 loc) · 74.2 KB
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
#
# Copyright (c) 2018-2023 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.
#
echo 'Running with parameters:'
echo " USE_CASE: ${USE_CASE}"
echo " FRAMEWORK: ${FRAMEWORK}"
echo " WORKSPACE: ${WORKSPACE}"
echo " DATASET_LOCATION: ${DATASET_LOCATION}"
echo " CHECKPOINT_DIRECTORY: ${CHECKPOINT_DIRECTORY}"
echo " BACKBONE_MODEL_DIRECTORY: ${BACKBONE_MODEL_DIRECTORY}"
echo " IN_GRAPH: ${IN_GRAPH}"
echo " MOUNT_INTELAI_MODELS_COMMON_SOURCE_DIR: ${MOUNT_INTELAI_MODELS_COMMON_SOURCE}"
if [ -n "${DOCKER}" ]; then
echo " Mounted volumes:"
echo " ${BENCHMARK_SCRIPTS} mounted on: ${MOUNT_BENCHMARK}"
echo " ${EXTERNAL_MODELS_SOURCE_DIRECTORY} mounted on: ${MOUNT_EXTERNAL_MODELS_SOURCE}"
echo " ${INTELAI_MODELS} mounted on: ${MOUNT_INTELAI_MODELS_SOURCE}"
echo " ${DATASET_LOCATION_VOL} mounted on: ${DATASET_LOCATION}"
echo " ${CHECKPOINT_DIRECTORY_VOL} mounted on: ${CHECKPOINT_DIRECTORY}"
echo " ${BACKBONE_MODEL_DIRECTORY_VOL} mounted on: ${BACKBONE_MODEL_DIRECTORY}"
fi
echo " SOCKET_ID: ${SOCKET_ID}"
echo " MODEL_NAME: ${MODEL_NAME}"
echo " MODE: ${MODE}"
echo " PRECISION: ${PRECISION}"
echo " BATCH_SIZE: ${BATCH_SIZE}"
echo " NUM_CORES: ${NUM_CORES}"
echo " BENCHMARK_ONLY: ${BENCHMARK_ONLY}"
echo " ACCURACY_ONLY: ${ACCURACY_ONLY}"
echo " OUTPUT_RESULTS: ${OUTPUT_RESULTS}"
echo " DISABLE_TCMALLOC: ${DISABLE_TCMALLOC}"
echo " TCMALLOC_LARGE_ALLOC_REPORT_THRESHOLD: ${TCMALLOC_LARGE_ALLOC_REPORT_THRESHOLD}"
echo " NOINSTALL: ${NOINSTALL}"
echo " OUTPUT_DIR: ${OUTPUT_DIR}"
echo " MPI_NUM_PROCESSES: ${MPI_NUM_PROCESSES}"
echo " MPI_NUM_PEOCESSES_PER_SOCKET: ${MPI_NUM_PROCESSES_PER_SOCKET}"
echo " MPI_HOSTNAMES: ${MPI_HOSTNAMES}"
echo " NUMA_CORES_PER_INSTANCE: ${NUMA_CORES_PER_INSTANCE}"
echo " PYTHON_EXE: ${PYTHON_EXE}"
echo " PYTHONPATH: ${PYTHONPATH}"
echo " DRY_RUN: ${DRY_RUN}"
echo " GPU: ${GPU}"
echo " ONEDNN_GRAPH: ${ONEDNN_GRAPH}"
# Enable GPU Flag
gpu_arg=""
is_model_gpu_supported="False"
if [ ${GPU} == "True" ]; then
gpu_arg="--gpu"
# Environment variables for GPU
export RenderCompressedBuffersEnabled=0
export CreateMultipleSubDevices=1
export ForceLocalMemoryAccessMode=1
export SYCL_PI_LEVEL_ZERO_BATCH_SIZE=1
else
unset RenderCompressedBuffersEnabled
unset CreateMultipleSubDevices
unset ForceLocalMemoryAccessMode
unset ForceNonSystemMemoryPlacement
unset TF_ENABLE_LAYOUT_OPT
unset SYCL_PI_LEVEL_ZERO_BATCH_SIZE
fi
# inference & training is supported right now
if [ ${MODE} != "inference" ] && [ ${MODE} != "training" ]; then
echo "${MODE} mode for ${MODEL_NAME} is not supported"
exit 1
fi
# Enable OneDNN Graph Flag
onednn_graph_arg=""
if [ ${ONEDNN_GRAPH} == "True" ]; then
onednn_graph_arg="--onednn-graph=True"
export ITEX_ONEDNN_GRAPH=1
fi
# Determines if we are running in a container by checking for .dockerenv
function _running-in-container()
{
# .dockerenv is a legacy mount populated by Docker engine and at some point it may go away.
[ -f /.dockerenv ]
}
# check if running on Windows OS
PLATFORM='unknown'
unamestr=`uname`
if [[ "$unamestr" == 'Linux' ]]; then
PLATFORM='linux'
elif [[ "$unamestr" == "MSYS"* ]]; then
PLATFORM='windows'
fi
echo
echo "Running on ${PLATFORM}"
echo
OS_PLATFORM=""
if [[ ${PLATFORM} == "linux" ]]; then
# Check the Linux PLATFORM distribution if CentOS, Debian or Ubuntu
OS_PLATFORM=$(egrep '^(NAME)=' /etc/os-release)
OS_PLATFORM=$(echo "${OS_PLATFORM#*=}")
OS_VERSION=$(egrep '^(VERSION_ID)=' /etc/os-release)
OS_VERSION=$(echo "${OS_VERSION#*=}")
echo "Running on ${OS_PLATFORM} version ${OS_VERSION}"
fi
if [[ ${NOINSTALL} != "True" ]]; then
# set env var before installs so that user interaction is not required
export DEBIAN_FRONTEND=noninteractive
# install common dependencies
# Handle horovod uniformly for all OSs.
# If a diffferent version need to be used for a specific OS
# change that variable alone locally in the large if stmts (below)
if [[ ${MPI_NUM_PROCESSES} != "None" && $MODE == "training" ]]; then
export HOROVOD_WITHOUT_PYTORCH=1
export HOROVOD_WITHOUT_MXNET=1
export HOROVOD_WITH_TENSORFLOW=1
export HOROVOD_VERSION=39c8f7c
fi
if [[ ${OS_PLATFORM} == *"CentOS"* ]] || [[ ${OS_PLATFORM} == *"Red Hat"* ]]; then
yum update -y
yum install -y gcc gcc-c++ cmake python3-tkinter libXext libSM
# install google-perftools for tcmalloc
if [[ ${DISABLE_TCMALLOC} != "True" ]]; then
if [[ ${OS_PLATFORM} == *"Red Hat"* ]] && [[ ${OS_VERSION} =~ "7".* ]]; then
# For Red Hat 7 we need to build from source
pushd .
yum install -y wget
GPERFTOOLS_VER="2.9.1"
wget https://github.com/gperftools/gperftools/releases/download/gperftools-${GPERFTOOLS_VER}/gperftools-${GPERFTOOLS_VER}.tar.gz -O gperftools-${GPERFTOOLS_VER}.tar.gz
tar -xvzf gperftools-${GPERFTOOLS_VER}.tar.gz
cd gperftools-${GPERFTOOLS_VER}
./configure --disable-cpu-profiler --disable-heap-profiler --disable-heap-checker --disable-debugalloc --enable-minimal
make
make install
LD_LIBRARY_PATH=“/usr/local/lib:${LD_LIBRARY_PATH}”
popd
else
if [[ ${OS_VERSION} =~ "7".* ]]; then
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && \
yum install -y https://extras.getpagespeed.com/release-el7-latest.rpm
elif [[ ${OS_VERSION} =~ "8".* ]]; then
# For Red Hat user needs to register the system first to be able to use the following repositories
# subscription-manager register --auto-attach
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm && \
yum install -y https://extras.getpagespeed.com/release-el8-latest.rpm
fi
yum install -y gperftools && \
yum clean all
fi
fi
if [[ ${MPI_NUM_PROCESSES} != "None" && $MODE == "training" ]]; then
# Installing OpenMPI
yum install -y openmpi openmpi-devel openssh openssh-server
yum clean all
export PATH="/usr/lib64/openmpi/bin:${PATH}"
# Install GCC 7 from devtoolset-7
if [[ ${OS_VERSION} =~ "7".* ]]; then
if [[ ${OS_PLATFORM} == *"CentOS"* ]]; then
yum install -y centos-release-scl
else
# For Red Hat user needs to register then enable the repo:
# subscription-manager repos --enable rhel-7-server-devtools-rpms
yum install -y scl-utils
fi
yum install -y devtoolset-7
export PATH="/opt/rh/devtoolset-7/root/usr/bin:${PATH}"
fi
# In case installing released versions of Horovod fail,and there is
# a working commit replace next set of commands with something like:
yum install -y git make
yum clean all
CC=gcc CXX=g++ python3 -m pip install --no-cache-dir git+https://github.com/horovod/horovod.git@${HOROVOD_VERSION}
horovodrun --check-build
fi
elif [[ ${OS_PLATFORM} == *"SLES"* ]] || [[ ${OS_PLATFORM} == *"SUSE"* ]]; then
zypper update -y
zypper install -y gcc gcc-c++ cmake python3-tk libXext6 libSM6
# install google-perftools for tcmalloc
if [[ ${DISABLE_TCMALLOC} != "True" ]]; then
zypper install -y gperftools && \
zypper clean all
fi
if [[ ${MPI_NUM_PROCESSES} != "None" && $MODE == "training" ]]; then
## Installing OpenMPI
zypper install -y openmpi3 openmpi3-devel openssh openssh-server
zypper clean all
export PATH="/usr/lib64/mpi/gcc/openmpi3/bin:${PATH}"
# In case installing released versions of Horovod fail,and there is
# a working commit replace next set of commands with something like:
zypper install -y git make
zypper clean all
CC=gcc CXX=g++ python3 -m pip install --no-cache-dir git+https://github.com/horovod/horovod.git@${HOROVOD_VERSION}
horovodrun --check-build
fi
elif [[ ${OS_PLATFORM} == *"Ubuntu"* ]] || [[ ${OS_PLATFORM} == *"Debian"* ]]; then
apt-get update -y
apt-get install gcc-9 g++-9 cmake python3-tk -y
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 700 --slave /usr/bin/g++ g++ /usr/bin/g++-7
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 900 --slave /usr/bin/g++ g++ /usr/bin/g++-9
apt-get install -y libsm6 libxext6 python3-dev
# install google-perftools for tcmalloc
if [[ ${DISABLE_TCMALLOC} != "True" ]]; then
apt-get install google-perftools -y
fi
if [[ ${MPI_NUM_PROCESSES} != "None" && $MODE == "training" ]]; then
# Installing OpenMPI
apt-get install openmpi-bin openmpi-common openssh-client openssh-server libopenmpi-dev -y
apt-get update
# In case installing released versions of Horovod fail,and there is
# a working commit replace next set of commands with something like:
apt-get install -y --no-install-recommends --fix-missing cmake git
# TODO: Once this PR https://github.com/horovod/horovod/pull/3864 is merged, we can install horovod as before.
CC=gcc CXX=g++ python3 -m pip install --no-cache-dir git+https://github.com/horovod/horovod.git@${HOROVOD_VERSION}
# Will keep this as reference for any future usecase
#git clone https://github.com/horovod/horovod.git
#cd horovod
#git reset --hard ${HOROVOD_VERSION}
#git submodule update --init --recursive
#git fetch origin pull/3864/head:ashahba/issue-3861-fix
#git checkout ashahba/issue-3861-fix
#python3 -m pip install --no-cache-dir -v -e .
horovodrun --check-build
fi
fi
python3 -m pip install --upgrade 'pip>=20.3.4'
python3 -m pip install requests
fi
# Determine if numactl needs to be installed
INSTALL_NUMACTL="False"
if [[ $NUMA_CORES_PER_INSTANCE != "None" || $SOCKET_ID != "-1" || $NUM_CORES != "-1" ]]; then
# The --numa-cores-per-instance, --socket-id, and --num-cores args use numactl
INSTALL_NUMACTL="True"
elif [[ $MODEL_NAME == "bert_large" && $MODE == "training" && $MPI_NUM_PROCESSES != "None" ]]; then
# BERT large training with MPI uses numactl
INSTALL_NUMACTL="True"
fi
# If we are running in a container, call the container_init.sh files
if [[ ${NOINSTALL} != "True" ]]; then
if _running-in-container ; then
# For running inside a real CentOS container
if [[ ${OS_PLATFORM} == *"CentOS"* ]] || [[ ${OS_PLATFORM} == *"Red Hat"* ]]; then
# Next if block only applies to CentOS 8. Please see here:
# https://forums.centos.org/viewtopic.php?f=54&t=78708
if [[ ! ${OS_VERSION} =~ "8".* ]] && [[ ${OS_PLATFORM} != *"Stream"* ]] && [[ ${OS_PLATFORM} != *"Red Hat"* ]]; then
sed -i '/^mirrorlist=/s/mirrorlist=/#mirrorlist=/g' /etc/yum.repos.d/CentOS-Linux-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*
yum clean all
yum distro-sync -y
fi
if [[ $INSTALL_NUMACTL == "True" ]]; then
yum update -y
yum install -y numactl
fi
elif [[ ${OS_PLATFORM} == *"SLES"* ]] || [[ ${OS_PLATFORM} == *"SUSE"* ]]; then
if [[ $INSTALL_NUMACTL == "True" ]]; then
zypper update -y
zypper install -y numactl
fi
elif [[ ${OS_PLATFORM} == *"Ubuntu"* ]] || [[ ${OS_PLATFORM} == *"Debian"* ]]; then
# For ubuntu, run the container_init.sh scripts
if [ -f ${MOUNT_BENCHMARK}/common/${FRAMEWORK}/container_init.sh ]; then
# Call the framework's container_init.sh, if it exists and we are running on ubuntu
INSTALL_NUMACTL=$INSTALL_NUMACTL ${MOUNT_BENCHMARK}/common/${FRAMEWORK}/container_init.sh
fi
# Call the model specific container_init.sh, if it exists
if [ -f ${MOUNT_BENCHMARK}/${USE_CASE}/${FRAMEWORK}/${MODEL_NAME}/${MODE}/${PRECISION}/container_init.sh ]; then
${MOUNT_BENCHMARK}/${USE_CASE}/${FRAMEWORK}/${MODEL_NAME}/${MODE}/${PRECISION}/container_init.sh
fi
fi
fi
fi
verbose_arg=""
if [ ${VERBOSE} == "True" ]; then
verbose_arg="--verbose"
fi
weight_sharing_arg=""
if [ ${WEIGHT_SHARING} == "True" ]; then
weight_sharing_arg="--weight-sharing"
fi
synthetic_data_arg=""
if [ ${SYNTHETIC_DATA} == "True" ]; then
synthetic_data_arg="--synthetic-data"
fi
accuracy_only_arg=""
if [ ${ACCURACY_ONLY} == "True" ]; then
accuracy_only_arg="--accuracy-only"
fi
benchmark_only_arg=""
if [ ${BENCHMARK_ONLY} == "True" ]; then
benchmark_only_arg="--benchmark-only"
fi
output_results_arg=""
if [ ${OUTPUT_RESULTS} == "True" ]; then
output_results_arg="--output-results"
fi
numa_cores_per_instance_arg=""
if [[ -n ${NUMA_CORES_PER_INSTANCE} && ${NUMA_CORES_PER_INSTANCE} != "None" ]]; then
numa_cores_per_instance_arg="--numa-cores-per-instance=${NUMA_CORES_PER_INSTANCE}"
fi
RUN_SCRIPT_PATH="common/${FRAMEWORK}/run_tf_benchmark.py"
timestamp=`date +%Y%m%d_%H%M%S`
LOG_FILENAME="benchmark_${MODEL_NAME}_${MODE}_${PRECISION}_${timestamp}.log"
if [ ! -d "${OUTPUT_DIR}" ]; then
mkdir ${OUTPUT_DIR}
fi
export PYTHONPATH=${PYTHONPATH}:${MOUNT_INTELAI_MODELS_COMMON_SOURCE}:${MOUNT_INTELAI_MODELS_SOURCE}
# Common execution command used by all models
function run_model() {
if [ ${is_model_gpu_supported} == "False" ] && [ ${GPU} == "True" ]; then
echo "Runing ${MODEL_NAME} ${MODE} with precision ${PRECISION} does not support --gpu."
exit 1
fi
# Navigate to the main benchmark directory before executing the script,
# since the scripts use the benchmark/common scripts as well.
cd ${MOUNT_BENCHMARK}
# Start benchmarking
if [[ -z $DRY_RUN ]]; then
if [[ -z $numa_cores_per_instance_arg ]]; then
eval ${CMD} 2>&1 | tee ${LOGFILE}
else
# Don't tee to a log file for numactl multi-instance runs
eval ${CMD}
fi
else
echo ${CMD}
return
fi
if [ ${VERBOSE} == "True" ]; then
echo "PYTHONPATH: ${PYTHONPATH}" | tee -a ${LOGFILE}
echo "RUNCMD: ${CMD} " | tee -a ${LOGFILE}
if [[ ${BATCH_SIZE} != "-1" ]]; then
echo "Batch Size: ${BATCH_SIZE}" | tee -a ${LOGFILE}
fi
fi
if [[ ${BATCH_SIZE} != "-1" ]]; then
echo "Ran ${MODE} with batch size ${BATCH_SIZE}" | tee -a ${LOGFILE}
fi
# if it starts with /workspace then it's not a separate mounted dir
# so it's custom and is in same spot as LOGFILE is, otherwise it's mounted in a different place
if [[ "${OUTPUT_DIR}" = "/workspace"* ]]; then
LOG_LOCATION_OUTSIDE_CONTAINER=${BENCHMARK_SCRIPTS}/common/${FRAMEWORK}/logs/${LOG_FILENAME}
else
LOG_LOCATION_OUTSIDE_CONTAINER=${LOGFILE}
fi
# Don't print log file location for numactl multi-instance runs, because those have
# separate log files for each instance
if [[ -z $numa_cores_per_instance_arg ]]; then
echo "Log file location: ${LOG_LOCATION_OUTSIDE_CONTAINER}" | tee -a ${LOGFILE}
fi
}
# basic run command with commonly used args
CMD="${PYTHON_EXE} ${RUN_SCRIPT_PATH} \
--framework=${FRAMEWORK} \
--use-case=${USE_CASE} \
--model-name=${MODEL_NAME} \
--precision=${PRECISION} \
--mode=${MODE} \
--benchmark-dir=${MOUNT_BENCHMARK} \
--intelai-models=${MOUNT_INTELAI_MODELS_SOURCE} \
--num-cores=${NUM_CORES} \
--batch-size=${BATCH_SIZE} \
--socket-id=${SOCKET_ID} \
--output-dir=${OUTPUT_DIR} \
--num-train-steps=${NUM_TRAIN_STEPS} \
${numa_cores_per_instance_arg} \
${accuracy_only_arg} \
${benchmark_only_arg} \
${output_results_arg} \
${weight_sharing_arg} \
${synthetic_data_arg} \
${verbose_arg} \
${gpu_arg} \
${onednn_graph_arg}"
if [ ${MOUNT_EXTERNAL_MODELS_SOURCE} != "None" ]; then
CMD="${CMD} --model-source-dir=${MOUNT_EXTERNAL_MODELS_SOURCE}"
fi
if [[ -n "${IN_GRAPH}" && ${IN_GRAPH} != "" ]]; then
CMD="${CMD} --in-graph=${IN_GRAPH}"
fi
if [[ -n "${CHECKPOINT_DIRECTORY}" && ${CHECKPOINT_DIRECTORY} != "" ]]; then
CMD="${CMD} --checkpoint=${CHECKPOINT_DIRECTORY}"
fi
if [[ -n "${BACKBONE_MODEL_DIRECTORY}" && ${BACKBONE_MODEL_DIRECTORY} != "" ]]; then
CMD="${CMD} --backbone-model=${BACKBONE_MODEL_DIRECTORY}"
fi
if [[ -n "${DATASET_LOCATION}" && ${DATASET_LOCATION} != "" ]]; then
CMD="${CMD} --data-location=${DATASET_LOCATION}"
fi
if [ ${NUM_INTER_THREADS} != "None" ]; then
CMD="${CMD} --num-inter-threads=${NUM_INTER_THREADS}"
fi
if [ ${NUM_INTRA_THREADS} != "None" ]; then
CMD="${CMD} --num-intra-threads=${NUM_INTRA_THREADS}"
fi
if [ ${DATA_NUM_INTER_THREADS} != "None" ]; then
CMD="${CMD} --data-num-inter-threads=${DATA_NUM_INTER_THREADS}"
fi
if [ ${DATA_NUM_INTRA_THREADS} != "None" ]; then
CMD="${CMD} --data-num-intra-threads=${DATA_NUM_INTRA_THREADS}"
fi
if [ ${DISABLE_TCMALLOC} != "None" ]; then
CMD="${CMD} --disable-tcmalloc=${DISABLE_TCMALLOC}"
fi
## Added for bert
function bert_options() {
if [[ ${MODE} == "training" ]]; then
if [[ -z "${TRAIN_OPTION}" ]]; then
echo "Error: Please specify a train option (SQuAD, Classifier, Pretraining)"
exit 1
fi
CMD=" ${CMD} --train-option=${TRAIN_OPTION}"
fi
if [[ ${MODE} == "inference" ]]; then
if [[ -z "${INFER_OPTION}" ]]; then
echo "Error: Please specify a inference option (SQuAD, Classifier, Pretraining)"
exit 1
fi
CMD=" ${CMD} --infer-option=${INFER_OPTION}"
fi
if [[ -n "${INIT_CHECKPOINT}" && ${INIT_CHECKPOINT} != "" ]]; then
CMD=" ${CMD} --init-checkpoint=${INIT_CHECKPOINT}"
fi
if [[ -n "${TASK_NAME}" && ${TASK_NAME} != "" ]]; then
CMD=" ${CMD} --task-name=${TASK_NAME}"
fi
if [[ -n "${WARMUP_STEPS}" && ${WARMUP_STEPS} != "" ]]; then
CMD=" ${CMD} --warmup-steps=${WARMUP_STEPS}"
fi
if [[ -n "${STEPS}" && ${STEPS} != "" ]]; then
CMD=" ${CMD} --steps=${STEPS}"
fi
if [[ -n "${VOCAB_FILE}" && ${VOCAB_FILE} != "" ]]; then
CMD=" ${CMD} --vocab-file=${VOCAB_FILE}"
fi
if [[ -n "${CONFIG_FILE}" && ${CONFIG_FILE} != "" ]]; then
CMD=" ${CMD} --config-file=${CONFIG_FILE}"
fi
if [[ -n "${DO_PREDICT}" && ${DO_PREDICT} != "" ]]; then
CMD=" ${CMD} --do-predict=${DO_PREDICT}"
fi
if [[ -n "${PREDICT_FILE}" && ${PREDICT_FILE} != "" ]]; then
CMD=" ${CMD} --predict-file=${PREDICT_FILE}"
fi
if [[ -n "${DO_TRAIN}" && ${DO_TRAIN} != "" ]]; then
CMD=" ${CMD} --do-train=${DO_TRAIN}"
fi
if [[ -n "${TRAIN_FILE}" && ${TRAIN_FILE} != "" ]]; then
CMD=" ${CMD} --train-file=${TRAIN_FILE}"
fi
if [[ -n "${NUM_TRAIN_EPOCHS}" && ${NUM_TRAIN_EPOCHS} != "" ]]; then
CMD=" ${CMD} --num-train-epochs=${NUM_TRAIN_EPOCHS}"
fi
if [[ -n "${NUM_TRAIN_STEPS}" && ${NUM_TRAIN_STEPS} != "" ]]; then
CMD=" ${CMD} --num-train-steps=${NUM_TRAIN_STEPS}"
fi
if [[ -n "${MAX_PREDICTIONS}" && ${MAX_PREDICTIONS} != "" ]]; then
CMD=" ${CMD} --max-predictions=${MAX_PREDICTIONS}"
fi
if [[ -n "${LEARNING_RATE}" && ${LEARNING_RATE} != "" ]]; then
CMD=" ${CMD} --learning-rate=${LEARNING_RATE}"
fi
if [[ -n "${MAX_SEQ_LENGTH}" && ${MAX_SEQ_LENGTH} != "" ]]; then
CMD=" ${CMD} --max-seq-length=${MAX_SEQ_LENGTH}"
fi
if [[ -n "${DOC_STRIDE}" && ${DOC_STRIDE} != "" ]]; then
CMD=" ${CMD} --doc-stride=${DOC_STRIDE}"
fi
if [[ -n "${INPUT_FILE}" && ${INPUT_FILE} != "" ]]; then
CMD=" ${CMD} --input-file=${INPUT_FILE}"
fi
if [[ -n "${DO_EVAL}" && ${DO_EVAL} != "" ]]; then
CMD=" ${CMD} --do-eval=${DO_EVAL}"
fi
if [[ -n "${DATA_DIR}" && ${DATA_DIR} != "" ]]; then
CMD=" ${CMD} --data-dir=${DATA_DIR}"
fi
if [[ -n "${DO_LOWER_CASE}" && ${DO_LOWER_CASE} != "" ]]; then
CMD=" ${CMD} --do-lower-case=${DO_LOWER_CASE}"
fi
if [[ -n "${ACCUM_STEPS}" && ${ACCUM_STEPS} != "" ]]; then
CMD=" ${CMD} --accum_steps=${ACCUM_STEPS}"
fi
if [[ -n "${PROFILE}" && ${PROFILE} != "" ]]; then
CMD=" ${CMD} --profile=${PROFILE}"
fi
if [[ -n "${EXPERIMENTAL_GELU}" && ${EXPERIMENTAL_GELU} != "" ]]; then
CMD=" ${CMD} --experimental-gelu=${EXPERIMENTAL_GELU}"
fi
if [[ -n "${OPTIMIZED_SOFTMAX}" && ${OPTIMIZED_SOFTMAX} != "" ]]; then
CMD=" ${CMD} --optimized-softmax=${OPTIMIZED_SOFTMAX}"
fi
if [[ -n "${MPI_WORKERS_SYNC_GRADIENTS}" && ${MPI_WORKERS_SYNC_GRADIENTS} != "" ]]; then
CMD=" ${CMD} --mpi_workers_sync_gradients=${MPI_WORKERS_SYNC_GRADIENTS}"
fi
}
## Added for BERT-large model from HuggingFace
function bert_large_hf_options() {
# For accuracy, dataset location is required
if [ "${DATASET_LOCATION_VOL}" == None ]; then
if [ ${ACCURACY_ONLY} == "True" ]; then
echo "No dataset directory specified, accuracy cannot be calculated."
exit 1
else
# Download model from huggingface.co/models for benchmarking
CMD=" ${CMD} --model-name-or-path=bert-large-uncased-whole-word-masking"
fi
else
CMD=" ${CMD} --model-name-or-path=${DATASET_LOCATION_VOL}"
fi
if [[ -n "${DATASET_NAME}" && ${DATASET_NAME} != "" ]]; then
CMD=" ${CMD} --dataset-name=${DATASET_NAME}"
fi
if [[ -n "${WARMUP_STEPS}" && ${WARMUP_STEPS} != "" ]]; then
CMD=" ${CMD} --warmup-steps=${WARMUP_STEPS}"
fi
if [[ -n "${STEPS}" && ${STEPS} != "" ]]; then
CMD=" ${CMD} --steps=${STEPS}"
fi
}
function install_protoc() {
pushd "${MOUNT_EXTERNAL_MODELS_SOURCE}/research"
# install protoc, if necessary, then compile protoc files
if [ ! -f "bin/protoc" ]; then
install_location=$1
echo "protoc not found, installing protoc from ${install_location}"
if [[ ${OS_PLATFORM} == *"CentOS"* ]] || [[ ${OS_PLATFORM} == *"Red Hat"* ]]; then
yum update -y && yum install -y unzip wget
else
apt-get update && apt-get install -y unzip wget
fi
wget -O protobuf.zip ${install_location}
unzip -o protobuf.zip
rm protobuf.zip
else
echo "protoc already found"
fi
echo "Compiling protoc files"
./bin/protoc object_detection/protos/*.proto --python_out=.
popd
}
function get_cocoapi() {
# get arg for where the cocoapi repo was cloned
cocoapi_dir=${1}
# get arg for the location where we want the pycocotools
parent_dir=${2}
pycocotools_dir=${parent_dir}/pycocotools
# If pycoco tools aren't already found, then builds the coco python API
if [ ! -d ${pycocotools_dir} ]; then
# This requires that the cocoapi is cloned in the external model source dir
if [ -d "${cocoapi_dir}/PythonAPI" ]; then
# install cocoapi
pushd ${cocoapi_dir}/PythonAPI
echo "Installing COCO API"
make
cp -r pycocotools ${parent_dir}
popd
else
echo "${cocoapi_dir}/PythonAPI directory was not found"
echo "Unable to install the python cocoapi."
exit 1
fi
else
echo "pycocotools were found at: ${pycocotools_dir}"
fi
}
function add_arg() {
local arg_str=""
if [ -n "${2}" ]; then
arg_str=" ${1}=${2}"
fi
echo "${arg_str}"
}
function add_steps_args() {
# returns string with --steps and --warmup_steps, if there are values specified
local steps_arg=""
local trainepochs_arg=""
local epochsbtweval_arg=""
local warmup_steps_arg=""
local kmp_blocktime_arg=""
if [ -n "${STEPS}" ]; then
steps_arg="--steps=${STEPS}"
fi
if [ -n "${TRAIN_EPOCHS}" ]; then
trainepochs_arg="--train_epochs=${TRAIN_EPOCHS}"
fi
if [ -n "${EPOCHS_BETWEEN_EVALS}" ]; then
epochsbtweval_arg="--epochs_between_evals=${EPOCHS_BETWEEN_EVALS}"
fi
if [ -n "${WARMUP_STEPS}" ]; then
warmup_steps_arg="--warmup-steps=${WARMUP_STEPS}"
fi
if [ -n "${KMP_BLOCKTIME}" ]; then
kmp_blocktime_arg="--kmp-blocktime=${KMP_BLOCKTIME}"
fi
echo "${steps_arg} ${trainepochs_arg} ${epochsbtweval_arg} ${warmup_steps_arg} ${kmp_blocktime_arg}"
}
function add_calibration_arg() {
# returns string with --calibration-only, if True is specified,
# in this case a subset (~ 100 images) of the ImageNet dataset
# is generated to be used later on in calibrating the Int8 model.
# also this function returns a string with --calibrate, if True is specified,
# which enables resnet50 Int8 benchmark to run accuracy using the previously
# generated ImageNet data subset.
local calibration_arg=""
if [[ ${calibration_only} == "True" ]]; then
calibration_arg="--calibration-only"
elif [[ ${calibrate} == "True" ]]; then
calibration_arg="--calibrate=True"
fi
echo "${calibration_arg}"
}
# 3D UNet model
function 3d_unet() {
if [[ ${PRECISION} == "fp32" ]] && [[ ${MODE} == "inference" ]]; then
if [[ ${NOINSTALL} != "True" ]]; then
python3 -m pip install -r "${MOUNT_BENCHMARK}/${USE_CASE}/${FRAMEWORK}/${MODEL_NAME}/requirements.txt"
fi
export PYTHONPATH=${PYTHONPATH}:${MOUNT_INTELAI_MODELS_SOURCE}/inference/fp32
PYTHONPATH=${PYTHONPATH} CMD=${CMD} run_model
else
echo "${PRECISION} ${MODE} is not supported for ${MODEL_NAME}"
exit 1
fi
}
# MLPerf 3D UNet model
function 3d_unet_mlperf() {
# For accuracy, dataset location is required
# if [ "${DATASET_LOCATION_VOL}" == None ] && [ ${ACCURACY_ONLY} == "True" ]; then
# echo "No dataset directory specified, accuracy cannot be calculated."
# exit 1
# fi
CMD="${CMD} $(add_steps_args)"
if [ ${MODE} == "inference" ]; then
if [ ${PRECISION} == "fp32" ] || [ $PRECISION == "bfloat16" ] || [ $PRECISION == "int8" ]; then
if [ ${NOINSTALL} != "True" ]; then
echo "Installing requirements"
python3 -m pip install -r "${MOUNT_BENCHMARK}/${USE_CASE}/${FRAMEWORK}/${MODEL_NAME}/requirements.txt"
fi
export PYTHONPATH=${PYTHONPATH}:${MOUNT_INTELAI_MODELS_SOURCE}/inference/${PRECISION}
PYTHONPATH=${PYTHONPATH} CMD=${CMD} run_model
else
echo "${PRECISION} ${MODE} is not supported for ${MODEL_NAME}"
exit 1
fi
else
echo "${MODE} is not supported for ${MODEL_NAME}"
exit 1
fi
}
#BERT model
function bert() {
if [ ${PRECISION} == "fp32" ]; then
export PYTHONPATH=${PYTHONPATH}:${MOUNT_BENCHMARK}:${MOUNT_EXTERNAL_MODELS_SOURCE}
if [ ${NOINSTALL} != "True" ]; then
apt-get update && apt-get install -y git
python3 -m pip install -r ${MOUNT_BENCHMARK}/${USE_CASE}/${FRAMEWORK}/${MODEL_NAME}/requirements.txt
fi
CMD="${CMD} \
$(add_arg "--task_name" ${TASK_NAME}) \
$(add_arg "--max_seq_length" ${MAX_SEQ_LENGTH}) \
$(add_arg "--eval_batch_size" ${eval_batch_size}) \
$(add_arg "--learning_rate" ${LEARNING_RATE}) \
$(add_arg "--vocab_file" ${VOCAB_FILE}) \
$(add_arg "--bert_config_file" ${BERT_CONFIG_FILE}) \
$(add_arg "--init_checkpoint" ${INIT_CHECKPOINT})"
PYTHONPATH=${PYTHONPATH} CMD=${CMD} run_model
else
echo "PRECISION=${PRECISION} is not supported for ${MODEL_NAME}"
exit 1
fi
}
function dien_options() {
if [[ -n "${EXACT_MAX_LENGTH}" && ${EXACT_MAX_LENGTH} != "" ]]; then
CMD=" ${CMD} --exact-max-length=${EXACT_MAX_LENGTH}"
fi
if [[ -n "${GRAPH_TYPE}" && ${GRAPH_TYPE} != "" ]]; then
CMD=" ${CMD} --graph_type=${GRAPH_TYPE}"
fi
if [[ -n "${NUM_ITERATIONS}" && ${NUM_ITERATIONS} != "" ]]; then
CMD=" ${CMD} --num-iterations=${NUM_ITERATIONS}"
fi
if [[ -n "${PRECISION}" && ${PRECISION} != "" ]]; then
CMD=" ${CMD} --data-type=${PRECISION}"
fi
}
# DIEN model
function dien() {
if [ ${MODE} == "inference" ]; then
if [ ${PRECISION} == "fp32" ] || [ ${PRECISION} == "bfloat16" ]; then
dien_options
CMD=${CMD} run_model
else
echo "PRECISION=${PRECISION} not supported for ${MODEL_NAME}"
exit 1
fi
elif [ ${MODE} == "training" ]; then
if [ ${PRECISION} == "fp32" ] || [ ${PRECISION} == "bfloat16" ]; then
dien_options
CMD=${CMD} run_model
else
echo "PRECISION=${PRECISION} not supported for ${MODEL_NAME}"
exit 1
fi
fi
}
# DCGAN model
function dcgan() {
if [ ${PRECISION} == "fp32" ]; then
export PYTHONPATH=${PYTHONPATH}:${MOUNT_EXTERNAL_MODELS_SOURCE}/research:${MOUNT_EXTERNAL_MODELS_SOURCE}/research/slim:${MOUNT_EXTERNAL_MODELS_SOURCE}/research/gan/cifar
PYTHONPATH=${PYTHONPATH} CMD=${CMD} run_model
else
echo "PRECISION=${PRECISION} is not supported for ${MODEL_NAME}"
exit 1
fi
}
# DenseNet 169 model
function densenet169() {
if [ ${PRECISION} == "fp32" ]; then
CMD="${CMD} $(add_arg "--input_height" ${INPUT_HEIGHT}) $(add_arg "--input_width" ${INPUT_WIDTH}) \
$(add_arg "--warmup_steps" ${WARMUP_STEPS}) $(add_arg "--steps" ${STEPS}) $(add_arg "--input_layer" ${INPUT_LAYER}) \
$(add_arg "--output_layer" ${OUTPUT_LAYER})"
PYTHONPATH=${PYTHONPATH} CMD=${CMD} run_model
else
echo "PRECISION=${PRECISION} is not supported for ${MODEL_NAME}"
exit 1
fi
}
# Faster R-CNN (ResNet50) model
function faster_rcnn() {
export PYTHONPATH=$PYTHONPATH:${MOUNT_EXTERNAL_MODELS_SOURCE}/research:${MOUNT_EXTERNAL_MODELS_SOURCE}/research/slim
original_dir=$(pwd)
if [ ${NOINSTALL} != "True" ]; then
# install dependencies
python3 -m pip install -r "${MOUNT_BENCHMARK}/object_detection/tensorflow/faster_rcnn/requirements.txt"
cd "${MOUNT_EXTERNAL_MODELS_SOURCE}/research"
# install protoc v3.3.0, if necessary, then compile protoc files
install_protoc "https://github.com/google/protobuf/releases/download/v3.3.0/protoc-3.3.0-linux-x86_64.zip"
# Install git so that we can apply the patch
apt-get update && apt-get install -y git
fi
# Apply the patch to the tensorflow/models repo with fixes for the accuracy
# script and for running with python 3
cd ${MOUNT_EXTERNAL_MODELS_SOURCE}
git apply ${MOUNT_INTELAI_MODELS_SOURCE}/${MODE}/${PRECISION}/faster_rcnn.patch
if [ ${PRECISION} == "fp32" ]; then
if [ -n "${CONFIG_FILE}" ]; then
CMD="${CMD} --config_file=${CONFIG_FILE}"
fi
if [[ -z "${CONFIG_FILE}" ]] && [ ${BENCHMARK_ONLY} == "True" ]; then
echo "Fast R-CNN requires -- config_file arg to be defined"
exit 1
fi
elif [ ${PRECISION} == "int8" ]; then
number_of_steps_arg=""
if [ -n "${NUMBER_OF_STEPS}" ] && [ ${BENCHMARK_ONLY} == "True" ]; then
CMD="${CMD} --number-of-steps=${NUMBER_OF_STEPS}"
fi
else
echo "PRECISION=${PRECISION} is not supported for ${MODEL_NAME}"
exit 1
fi
cd $original_dir
PYTHONPATH=${PYTHONPATH} CMD=${CMD} run_model
}
# inceptionv4 model
function inceptionv4() {
# For accuracy, dataset location is required
if [ "${DATASET_LOCATION_VOL}" == None ] && [ ${ACCURACY_ONLY} == "True" ]; then
echo "No dataset directory specified, accuracy cannot be calculated."
exit 1
fi
# add extra model specific args and then run the model
CMD="${CMD} $(add_steps_args) $(add_arg "--input-height" ${INPUT_HEIGHT}) \
$(add_arg "--input-width" ${INPUT_WIDTH}) $(add_arg "--input-layer" ${INPUT_LAYER}) \
$(add_arg "--output-layer" ${OUTPUT_LAYER})"
if [ ${PRECISION} == "int8" ]; then
PYTHONPATH=${PYTHONPATH} CMD=${CMD} run_model
elif [ ${PRECISION} == "fp32" ]; then
PYTHONPATH=${PYTHONPATH} CMD=${CMD} run_model
else
echo "PRECISION=${PRECISION} is not supported for ${MODEL_NAME}"
exit 1
fi
}
# Mask R-CNN model
function maskrcnn() {
if [ ${PRECISION} == "fp32" ]; then
original_dir=$(pwd)
if [ ${NOINSTALL} != "True" ]; then
# install dependencies
python3 -m pip install -r ${MOUNT_BENCHMARK}/image_segmentation/tensorflow/maskrcnn/inference/fp32/requirements.txt
fi
export PYTHONPATH=${PYTHONPATH}:${MOUNT_EXTERNAL_MODELS_SOURCE}:${MOUNT_EXTERNAL_MODELS_SOURCE}/mrcnn
CMD="${CMD} --data-location=${DATASET_LOCATION}"
PYTHONPATH=${PYTHONPATH} CMD=${CMD} run_model
else
echo "PRECISION=${PRECISION} is not supported for ${MODEL_NAME}"
exit 1
fi
}
# mobilenet_v1 model
function mobilenet_v1() {
if [ ${PRECISION} == "fp32" ] || [ ${PRECISION} == "bfloat16" ]; then
CMD="${CMD} $(add_arg "--input_height" ${INPUT_HEIGHT}) $(add_arg "--input_width" ${INPUT_WIDTH}) \
$(add_arg "--warmup_steps" ${WARMUP_STEPS}) $(add_arg "--steps" ${STEPS}) \
$(add_arg "--input_layer" ${INPUT_LAYER}) $(add_arg "--output_layer" ${OUTPUT_LAYER})"
PYTHONPATH=${PYTHONPATH} CMD=${CMD} run_model
elif [ ${PRECISION} == "int8" ]; then
CMD="${CMD} $(add_arg "--input_height" ${INPUT_HEIGHT}) $(add_arg "--input_width" ${INPUT_WIDTH}) \
$(add_arg "--warmup_steps" ${WARMUP_STEPS}) $(add_arg "--steps" ${STEPS}) \
$(add_arg "--input_layer" ${INPUT_LAYER}) $(add_arg "--output_layer" ${OUTPUT_LAYER}) \
$(add_calibration_arg)"
PYTHONPATH=${PYTHONPATH} CMD=${CMD} run_model
else
echo "PRECISION=${PRECISION} is not supported for ${MODEL_NAME}"
exit 1
fi
}
# mobilenet_v2 model
function mobilenet_v2() {
if [ ${PRECISION} == "fp32" ] || [ ${PRECISION} == "bfloat16" ]; then
CMD="${CMD} $(add_arg "--input_height" ${INPUT_HEIGHT}) $(add_arg "--input_width" ${INPUT_WIDTH}) \
$(add_arg "--warmup_steps" ${WARMUP_STEPS}) $(add_arg "--steps" ${STEPS}) \
$(add_arg "--input_layer" ${INPUT_LAYER}) $(add_arg "--output_layer" ${OUTPUT_LAYER})"
PYTHONPATH=${PYTHONPATH} CMD=${CMD} run_model
elif [ ${PRECISION} == "int8" ]; then
CMD="${CMD} $(add_arg "--input_height" ${INPUT_HEIGHT}) $(add_arg "--input_width" ${INPUT_WIDTH}) \
$(add_arg "--warmup_steps" ${WARMUP_STEPS}) $(add_arg "--steps" ${STEPS}) \
$(add_arg "--input_layer" ${INPUT_LAYER}) $(add_arg "--output_layer" ${OUTPUT_LAYER}) \
$(add_calibration_arg)"
PYTHONPATH=${PYTHONPATH} CMD=${CMD} run_model
else
echo "PRECISION=${PRECISION} is not supported for ${MODEL_NAME}"
exit 1
fi
}
# MTCC model
function mtcc() {
if [ ${PRECISION} == "fp32" ]; then
if [ ! -d "${DATASET_LOCATION}" ]; then
echo "No Data location specified, please follow MTCC README instaructions to download the dataset."
exit 1
fi
if [ ${NOINSTALL} != "True" ]; then
# install dependencies
python3 -m pip install opencv-python
python3 -m pip install easydict
fi
export PYTHONPATH=${PYTHONPATH}:${MOUNT_EXTERNAL_MODELS_SOURCE}:${MOUNT_EXTERNAL_MODELS_SOURCE}/Detection:${MOUNT_INTELAI_MODELS_SOURCE}/inference/fp32:${MOUNT_INTELAI_MODELS_SOURCE}/inference/fp32/Detection
PYTHONPATH=${PYTHONPATH} CMD=${CMD} run_model
else
echo "PRECISION=${PRECISION} is not supported for ${MODEL_NAME}"
exit 1
fi
}
# NCF model
function ncf() {
if [[ -n "${clean}" ]]; then
CMD="${CMD} --clean"
fi