Skip to content

Commit e3cc766

Browse files
aqtjinhkvision
authored andcommitted
Add python examples auto test to jenkins (intel#1834)
* auto-test * fix openvino memory * fix openvino memory * keras2 * fix keras2 * fix * fix * fix k2 * fix k2 * temporary version * test for #6 * keras test * test nc * test nc * final * final fix * final fix * ffffinal fix * fix * f * f
1 parent d9b25ba commit e3cc766

File tree

4 files changed

+272
-4
lines changed

4 files changed

+272
-4
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
export SPARK_HOME=$SPARK_HOME
4+
export MASTER=local[4]
5+
export FTP_URI=$FTP_URI
6+
export ANALYTICS_ZOO_ROOT=$ANALYTICS_ZOO_ROOT
7+
export ANALYTICS_ZOO_HOME=$ANALYTICS_ZOO_ROOT/dist
8+
9+
set -e
10+
11+
echo "#1 start example test for attention"
12+
#timer
13+
start=$(date "+%s")
14+
sed "s/max_features = 20000/max_features = 100/g;s/max_len = 200/max_len = 10/g;s/hidden_size=128/hidden_size=8/g" \
15+
${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/attention/transformer.py \
16+
> ${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/attention/tmp.py
17+
18+
${ANALYTICS_ZOO_HOME}/bin/spark-submit-python-with-zoo.sh \
19+
--conf spark.executor.extraJavaOptions="-Xss512m" \
20+
--conf spark.driver.extraJavaOptions="-Xss512m" \
21+
--master ${MASTER} \
22+
--driver-memory 20g \
23+
--executor-memory 100g \
24+
${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/attention/tmp.py
25+
26+
now=$(date "+%s")
27+
time1=$((now-start))
28+
echo "#1 attention time used:$time1 seconds"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
clear_up () {
3+
echo "Clearing up environment. Uninstalling analytics-zoo"
4+
pip uninstall -y analytics-zoo
5+
pip uninstall -y bigdl
6+
pip uninstall -y pyspark
7+
}
8+
9+
echo "#1 start example test for attention"
10+
start=$(date "+%s")
11+
sed "s/max_features = 20000/max_features = 200/g;s/max_len = 200/max_len = 20/g;s/hidden_size=128/hidden_size=8/g" \
12+
${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/attention/transformer.py \
13+
> ${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/attention/tmp.py
14+
export SPARK_DRIVER_MEMORY=20g
15+
python ${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/attention/tmp.py
16+
17+
exit_status=$?
18+
if [ $exit_status -ne 0 ];
19+
then
20+
clear_up
21+
echo "attention failed"
22+
exit $exit_status
23+
fi
24+
25+
unset SPARK_DRIVER_MEMORY
26+
now=$(date "+%s")
27+
time1=$((now-start))
28+
echo "attention time used:$time1 seconds"

pyzoo/zoo/examples/run-example-tests-pip.sh

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,95 @@ unset SPARK_DRIVER_MEMORY
488488
now=$(date "+%s")
489489
time10=$((now-start))
490490

491+
echo "#12 start example test for vnni/openvino"
492+
start=$(date "+%s")
493+
if [ -d analytics-zoo-models/vnni ]
494+
then
495+
echo "analytics-zoo-models/resnet_v1_50.xml already exists."
496+
else
497+
wget $FTP_URI/analytics-zoo-models/openvino/vnni/resnet_v1_50.zip \
498+
-P analytics-zoo-models
499+
unzip -q analytics-zoo-models/resnet_v1_50.zip -d analytics-zoo-models/vnni
500+
fi
501+
if [ -d analytics-zoo-data/data/object-detection-coco ]
502+
then
503+
echo "analytics-zoo-data/data/object-detection-coco already exists"
504+
else
505+
wget $FTP_URI/analytics-zoo-data/data/object-detection-coco.zip -P analytics-zoo-data/data
506+
unzip -q analytics-zoo-data/data/object-detection-coco.zip -d analytics-zoo-data/data
507+
fi
508+
export SPARK_DRIVER_MEMORY=2g
509+
python ${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/vnni/openvino/predict.py \
510+
--model analytics-zoo-models/vnni/resnet_v1_50.xml \
511+
--image analytics-zoo-data/data/object-detection-coco
512+
513+
exit_status=$?
514+
if [ $exit_status -ne 0 ];
515+
then
516+
clear_up
517+
echo "vnni/openvino failed"
518+
exit $exit_status
519+
fi
520+
521+
unset SPARK_DRIVER_MEMORY
522+
now=$(date "+%s")
523+
time12=$((now-start))
524+
525+
echo "#13 start example test for streaming Object Detection"
526+
#timer
527+
start=$(date "+%s")
528+
if [ -d analytics-zoo-data/data/object-detection-coco ]
529+
then
530+
echo "analytics-zoo-data/data/object-detection-coco already exists"
531+
else
532+
wget $FTP_URI/analytics-zoo-data/data/object-detection-coco.zip -P analytics-zoo-data/data
533+
unzip -q analytics-zoo-data/data/object-detection-coco.zip -d analytics-zoo-data/data/
534+
fi
535+
536+
if [ -f analytics-zoo-models/analytics-zoo_ssd-vgg16-300x300_COCO_0.1.0.model ]
537+
then
538+
echo "analytics-zoo-models/object-detection/analytics-zoo_ssd-vgg16-300x300_COCO_0.1.0.model already exists"
539+
else
540+
wget $FTP_URI/analytics-zoo-models/object-detection/analytics-zoo_ssd-vgg16-300x300_COCO_0.1.0.model \
541+
-P analytics-zoo-models
542+
fi
543+
544+
mkdir output
545+
mkdir stream
546+
export SPARK_DRIVER_MEMORY=2g
547+
while true
548+
do
549+
temp1=$(find analytics-zoo-data/data/object-detection-coco -type f|wc -l)
550+
temp2=$(find ./output -type f|wc -l)
551+
temp3=$(($temp1+$temp1))
552+
if [ $temp3 -eq $temp2 ];then
553+
kill -9 $(ps -ef | grep StreamingObjectDetection | grep -v grep |awk '{print $2}')
554+
rm -r output
555+
rm -r stream
556+
break
557+
fi
558+
done &
559+
python ${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/streaming/objectdetection/streaming_object_detection.py \
560+
--streaming_path ./stream \
561+
--model analytics-zoo-models/analytics-zoo_ssd-vgg16-300x300_COCO_0.1.0.model \
562+
--output_path ./output &
563+
python ${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/streaming/objectdetection/image_path_writer.py \
564+
--streaming_path ./stream \
565+
--img_path analytics-zoo-data/data/object-detection-coco
566+
567+
exit_status=$?
568+
if [ $exit_status -ne 0 ];
569+
then
570+
clear_up
571+
echo "streaming Object Detection failed"
572+
exit $exit_status
573+
fi
574+
575+
unset SPARK_DRIVER_MEMORY
576+
now=$(date "+%s")
577+
time13=$((now-start))
578+
579+
491580
# This should be done at the very end after all tests finish.
492581
clear_up
493582

@@ -501,3 +590,5 @@ echo "#7 pytorch time used: $time7 seconds"
501590
echo "#8 tensorflow time used: $time8 seconds"
502591
echo "#9 anomalydetection time used: $time9 seconds"
503592
echo "#10 qaranker time used: $time10 seconds"
593+
echo "#12 vnni/openvino time used: $time12 seconds"
594+
echo "#13 streaming Object Detection time used: $time13 seconds"

pyzoo/zoo/examples/run-example-tests.sh

Lines changed: 125 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,28 @@ ${SPARK_HOME}/bin/spark-submit \
4646
now=$(date "+%s")
4747
time1=$((now-start))
4848

49-
echo "#2 start example test for customized loss and layer (Funtional API)"
49+
echo "#2 start example test for autograd"
5050
#timer
5151
start=$(date "+%s")
52+
echo "#2.1 start example test for custom layer"
5253
${SPARK_HOME}/bin/spark-submit \
5354
--master ${MASTER} \
54-
--driver-memory 20g \
55-
--executor-memory 20g \
55+
--driver-memory 2g \
56+
--executor-memory 2g \
5657
--py-files ${ANALYTICS_ZOO_PYZIP},${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/autograd/custom.py \
5758
--jars ${ANALYTICS_ZOO_JAR} \
5859
--conf spark.driver.extraClassPath=${ANALYTICS_ZOO_JAR} \
5960
--conf spark.executor.extraClassPath=${ANALYTICS_ZOO_JAR} \
6061
${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/autograd/custom.py \
6162
--nb_epoch 2
63+
64+
echo "#2.2 start example test for customloss"
65+
${ANALYTICS_ZOO_HOME}/bin/spark-submit-python-with-zoo.sh \
66+
--master ${MASTER} \
67+
--driver-memory 2g \
68+
--executor-memory 2g \
69+
${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/autograd/customloss.py
70+
6271
now=$(date "+%s")
6372
time2=$((now-start))
6473

@@ -437,8 +446,117 @@ ${ANALYTICS_ZOO_HOME}/bin/spark-submit-python-with-zoo.sh \
437446
now=$(date "+%s")
438447
time10=$((now-start))
439448

449+
echo "#11 start example test for openvino"
450+
#timer
451+
start=$(date "+%s")
452+
if [ -f analytics-zoo-models/faster_rcnn_resnet101_coco_2018_01_28.tar.gz ]
453+
then
454+
echo "analytics-zoo-models/faster_rcnn_resnet101_coco already exists."
455+
else
456+
wget $FTP_URI/analytics-zoo-models/openvino/faster_rcnn_resnet101_coco_2018_01_28.tar.gz \
457+
-P analytics-zoo-models
458+
tar zxf analytics-zoo-models/faster_rcnn_resnet101_coco_2018_01_28.tar.gz -C analytics-zoo-models/
459+
fi
460+
if [ -d analytics-zoo-data/data/object-detection-coco ]
461+
then
462+
echo "analytics-zoo-data/data/object-detection-coco already exists"
463+
else
464+
wget $FTP_URI/analytics-zoo-data/data/object-detection-coco.zip -P analytics-zoo-data/data
465+
unzip -q analytics-zoo-data/data/object-detection-coco.zip -d analytics-zoo-data/data
466+
fi
467+
${ANALYTICS_ZOO_HOME}/bin/spark-submit-python-with-zoo.sh \
468+
--master ${MASTER} \
469+
--driver-memory 10g \
470+
--executor-memory 10g \
471+
${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/openvino/predict.py \
472+
--image analytics-zoo-data/data/object-detection-coco \
473+
--model analytics-zoo-models/faster_rcnn_resnet101_coco_2018_01_28
474+
now=$(date "+%s")
475+
time11=$((now-start))
476+
477+
echo "#12 start example for vnni/openvino"
478+
#timer
479+
start=$(date "+%s")
480+
if [ -d analytics-zoo-models/vnni ]
481+
then
482+
echo "analytics-zoo-models/resnet_v1_50.xml already exists."
483+
else
484+
wget $FTP_URI/analytics-zoo-models/openvino/vnni/resnet_v1_50.zip \
485+
-P analytics-zoo-models
486+
unzip -q analytics-zoo-models/resnet_v1_50.zip -d analytics-zoo-models/vnni
487+
fi
488+
if [ -d analytics-zoo-data/data/object-detection-coco ]
489+
then
490+
echo "analytics-zoo-data/data/object-detection-coco already exists"
491+
else
492+
wget $FTP_URI/analytics-zoo-data/data/object-detection-coco.zip -P analytics-zoo-data/data
493+
unzip -q analytics-zoo-data/data/object-detection-coco.zip -d analytics-zoo-data/data
494+
fi
495+
${ANALYTICS_ZOO_HOME}/bin/spark-submit-python-with-zoo.sh \
496+
--master ${MASTER} \
497+
--driver-memory 2g \
498+
--executor-memory 2g \
499+
${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/vnni/openvino/predict.py \
500+
--model analytics-zoo-models/vnni/resnet_v1_50.xml \
501+
--image analytics-zoo-data/data/object-detection-coco
502+
now=$(date "+%s")
503+
time12=$((now-start))
504+
505+
echo "#13 start example test for streaming Object Detection"
506+
#timer
507+
start=$(date "+%s")
508+
if [ -d analytics-zoo-data/data/object-detection-coco ]
509+
then
510+
echo "analytics-zoo-data/data/object-detection-coco already exists"
511+
else
512+
wget $FTP_URI/analytics-zoo-data/data/object-detection-coco.zip -P analytics-zoo-data/data
513+
unzip -q analytics-zoo-data/data/object-detection-coco.zip -d analytics-zoo-data/data/
514+
fi
515+
516+
if [ -f analytics-zoo-models/analytics-zoo_ssd-vgg16-300x300_COCO_0.1.0.model ]
517+
then
518+
echo "analytics-zoo-models/object-detection/analytics-zoo_ssd-vgg16-300x300_COCO_0.1.0.model already exists"
519+
else
520+
wget $FTP_URI/analytics-zoo-models/object-detection/analytics-zoo_ssd-vgg16-300x300_COCO_0.1.0.model \
521+
-P analytics-zoo-models
522+
fi
523+
524+
mkdir output
525+
mkdir stream
526+
while true
527+
do
528+
temp1=$(find analytics-zoo-data/data/object-detection-coco -type f|wc -l)
529+
temp2=$(find ./output -type f|wc -l)
530+
temp3=$(($temp1+$temp1))
531+
if [ $temp3 -eq $temp2 ];then
532+
kill -9 $(ps -ef | grep StreamingObjectDetection | grep -v grep |awk '{print $2}')
533+
rm -r output
534+
rm -r stream
535+
break
536+
fi
537+
done &
538+
${ANALYTICS_ZOO_HOME}/bin/spark-submit-python-with-zoo.sh \
539+
--master ${MASTER} \
540+
--driver-memory 2g \
541+
--executor-memory 2g \
542+
${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/streaming/objectdetection/streaming_object_detection.py \
543+
--streaming_path ./stream \
544+
--model analytics-zoo-models/analytics-zoo_ssd-vgg16-300x300_COCO_0.1.0.model \
545+
--output_path ./output &
546+
${ANALYTICS_ZOO_HOME}/bin/spark-submit-python-with-zoo.sh \
547+
--master ${MASTER} \
548+
--driver-memory 2g \
549+
--executor-memory 2g \
550+
${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/streaming/objectdetection/image_path_writer.py \
551+
--streaming_path ./stream \
552+
--img_path analytics-zoo-data/data/object-detection-coco
553+
554+
now=$(date "+%s")
555+
time13=$((now-start))
556+
557+
440558
echo "#1 textclassification time used: $time1 seconds"
441-
echo "#2 customized loss and layer time used: $time2 seconds"
559+
echo "#2 autograd time used: $time2 seconds"
442560
echo "#3 image-classification time used: $time3 seconds"
443561
echo "#4 object-detection loss and layer time used: $time4 seconds"
444562
echo "#5 nnframes time used: $time5 seconds"
@@ -447,3 +565,6 @@ echo "#7 anomalydetection time used: $time7 seconds"
447565
echo "#8 qaranker time used: $time8 seconds"
448566
echo "#9 inceptionV1 training time used: $time9 seconds"
449567
echo "#10 pytorch time used: $time10 seconds"
568+
echo "#11 openvino time used: $time11 seconds"
569+
echo "#12 vnni/openvino time used: $time12 seconds"
570+
echo "#13 streaming Object Detection time used: $time13 seconds"

0 commit comments

Comments
 (0)