From 8ac1d104eec303772b5e7984123fb5f0d185ad2f Mon Sep 17 00:00:00 2001 From: Anand Inguva Date: Wed, 10 Aug 2022 11:04:22 +0530 Subject: [PATCH 1/5] gradle task for tensor RT example E2E test --- build.gradle.kts | 2 ++ .../python/test-suites/dataflow/common.gradle | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index 3ce7a57b9305..ead19fea0ed9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -318,6 +318,7 @@ tasks.register("python37PostCommit") { dependsOn(":sdks:python:test-suites:direct:py37:spannerioIT") dependsOn(":sdks:python:test-suites:portable:py37:xlangSpannerIOIT") dependsOn(":sdks:python:test-suites:direct:py37:inferencePostCommitIT") + dependsOn(":sdks:python:test-suites:dataflow:py37:inferencePostCommitIT") } tasks.register("python38PostCommit") { @@ -333,6 +334,7 @@ tasks.register("python39PostCommit") { dependsOn(":sdks:python:test-suites:direct:py39:hdfsIntegrationTest") dependsOn(":sdks:python:test-suites:portable:py39:postCommitPy39") dependsOn(":sdks:python:test-suites:direct:py39:inferencePostCommitIT") + dependsOn(":sdks:python:test-suites:dataflow:py39:inferencePostCommitIT") } task("python37SickbayPostCommit") { diff --git a/sdks/python/test-suites/dataflow/common.gradle b/sdks/python/test-suites/dataflow/common.gradle index be278f6d3e3c..e1fdee16772f 100644 --- a/sdks/python/test-suites/dataflow/common.gradle +++ b/sdks/python/test-suites/dataflow/common.gradle @@ -364,3 +364,34 @@ task validatesContainer() { } } } + +def tensorRTTests = tasks.create("tensorRTtests") { + dependsOn 'installGcpTest' + dependsOn ':sdks:python:sdist' + doLast { + def testOpts = basicPytestOpts + def argMap = [ + "runner": "DataflowRunner", + "machine_type":"n1-standard-4", + "sdk_container_image": "us.gcr.io/apache-beam-testing/yeandy/apache_beam_tensorrt:latest", + "sdk_location": files(configurations.distTarBall.files).singleFile, + "project": "apache-beam-testing", + "region": "us-central1", + "input": "gs://apache-beam-testing-yeandy/tensorrt_image_file_names.txt", + "output": "gs://apache-beam-ml/outputs/tensorrt_predictions.txt", + "engine_path": "gs://apache-beam-ml/models/ssd_mobilenet_v2_320x320_coco17_tpu-8.trt" + ] + def cmdArgs = mapToArgString(argMap) + exec { + executable 'sh' + args '-c', ". ${envdir}/bin/activate && pip install pillow && python -m apache_beam.examples.inference.tensorrt_object_detection $cmdArgs --experiment=use_runner_v2 --experiment='worker_accelerator=type:nvidia-tesla-t4;count:1;install-nvidia-driver'" + } + } +} + +// add all RunInference E2E tests that run on DataflowRunner +project.tasks.register("inferencePostCommitIT") { + dependsOn = [ + 'tensorRTtests', + ] +} From 4fabc517b4b8538ba7a2cff06143875ea98f6156 Mon Sep 17 00:00:00 2001 From: Anand Inguva Date: Tue, 6 Sep 2022 16:46:53 -0400 Subject: [PATCH 2/5] Update input path and docker image --- sdks/python/test-suites/dataflow/common.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdks/python/test-suites/dataflow/common.gradle b/sdks/python/test-suites/dataflow/common.gradle index e1fdee16772f..5ebc96a12621 100644 --- a/sdks/python/test-suites/dataflow/common.gradle +++ b/sdks/python/test-suites/dataflow/common.gradle @@ -373,11 +373,11 @@ def tensorRTTests = tasks.create("tensorRTtests") { def argMap = [ "runner": "DataflowRunner", "machine_type":"n1-standard-4", - "sdk_container_image": "us.gcr.io/apache-beam-testing/yeandy/apache_beam_tensorrt:latest", + "sdk_container_image": "us.gcr.io/apache-beam-testing/python-postcommit-it/tensor_rt:latest", "sdk_location": files(configurations.distTarBall.files).singleFile, "project": "apache-beam-testing", "region": "us-central1", - "input": "gs://apache-beam-testing-yeandy/tensorrt_image_file_names.txt", + "input": "gs://apache-beam-ml/testing/inputs/tensorrt_image_file_names.txt", "output": "gs://apache-beam-ml/outputs/tensorrt_predictions.txt", "engine_path": "gs://apache-beam-ml/models/ssd_mobilenet_v2_320x320_coco17_tpu-8.trt" ] From 700e528d168b349c2f21cadcab78d0cb32065dc0 Mon Sep 17 00:00:00 2001 From: Anand Inguva Date: Tue, 6 Sep 2022 18:29:29 -0400 Subject: [PATCH 3/5] Add no_use_multiple_sdk_containers --- sdks/python/test-suites/dataflow/common.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdks/python/test-suites/dataflow/common.gradle b/sdks/python/test-suites/dataflow/common.gradle index 5ebc96a12621..b98b618ad5e5 100644 --- a/sdks/python/test-suites/dataflow/common.gradle +++ b/sdks/python/test-suites/dataflow/common.gradle @@ -384,7 +384,7 @@ def tensorRTTests = tasks.create("tensorRTtests") { def cmdArgs = mapToArgString(argMap) exec { executable 'sh' - args '-c', ". ${envdir}/bin/activate && pip install pillow && python -m apache_beam.examples.inference.tensorrt_object_detection $cmdArgs --experiment=use_runner_v2 --experiment='worker_accelerator=type:nvidia-tesla-t4;count:1;install-nvidia-driver'" + args '-c', ". ${envdir}/bin/activate && pip install pillow && python -m apache_beam.examples.inference.tensorrt_object_detection $cmdArgs --experiment=use_runner_v2 --experiment='worker_accelerator=type:nvidia-tesla-t4;count:1;install-nvidia-driver' --experiment=no_use_multiple_sdk_containers" } } } From 811ee31bd1ad96967c7f6153cd831e9a7700ef4a Mon Sep 17 00:00:00 2001 From: Anand Inguva Date: Wed, 7 Sep 2022 13:36:31 -0400 Subject: [PATCH 4/5] Add disk_size_gb for the example to work on Dataflow with Custom Image --- sdks/python/test-suites/dataflow/common.gradle | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sdks/python/test-suites/dataflow/common.gradle b/sdks/python/test-suites/dataflow/common.gradle index b98b618ad5e5..f26cec57b6ac 100644 --- a/sdks/python/test-suites/dataflow/common.gradle +++ b/sdks/python/test-suites/dataflow/common.gradle @@ -379,12 +379,13 @@ def tensorRTTests = tasks.create("tensorRTtests") { "region": "us-central1", "input": "gs://apache-beam-ml/testing/inputs/tensorrt_image_file_names.txt", "output": "gs://apache-beam-ml/outputs/tensorrt_predictions.txt", - "engine_path": "gs://apache-beam-ml/models/ssd_mobilenet_v2_320x320_coco17_tpu-8.trt" + "engine_path": "gs://apache-beam-ml/models/ssd_mobilenet_v2_320x320_coco17_tpu-8.trt", + "disk_size_gb": 75 ] def cmdArgs = mapToArgString(argMap) exec { executable 'sh' - args '-c', ". ${envdir}/bin/activate && pip install pillow && python -m apache_beam.examples.inference.tensorrt_object_detection $cmdArgs --experiment=use_runner_v2 --experiment='worker_accelerator=type:nvidia-tesla-t4;count:1;install-nvidia-driver' --experiment=no_use_multiple_sdk_containers" + args '-c', ". ${envdir}/bin/activate && pip install pillow && python -m apache_beam.examples.inference.tensorrt_object_detection $cmdArgs --experiment='worker_accelerator=type:nvidia-tesla-t4;count:1;install-nvidia-driver' --experiment=no_use_multiple_sdk_containers" } } } From 72f89a750398979a24ef146219ddbf56ab1f9a84 Mon Sep 17 00:00:00 2001 From: Anand Inguva Date: Wed, 7 Sep 2022 13:51:21 -0400 Subject: [PATCH 5/5] Add inference test to Python 3.8. Also add TODO for py37, py39 --- build.gradle.kts | 4 ++-- sdks/python/test-suites/dataflow/common.gradle | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index ead19fea0ed9..e9dd615dab68 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -318,7 +318,6 @@ tasks.register("python37PostCommit") { dependsOn(":sdks:python:test-suites:direct:py37:spannerioIT") dependsOn(":sdks:python:test-suites:portable:py37:xlangSpannerIOIT") dependsOn(":sdks:python:test-suites:direct:py37:inferencePostCommitIT") - dependsOn(":sdks:python:test-suites:dataflow:py37:inferencePostCommitIT") } tasks.register("python38PostCommit") { @@ -326,6 +325,8 @@ tasks.register("python38PostCommit") { dependsOn(":sdks:python:test-suites:direct:py38:postCommitIT") dependsOn(":sdks:python:test-suites:direct:py38:hdfsIntegrationTest") dependsOn(":sdks:python:test-suites:portable:py38:postCommitPy38") + // TODO: https://github.com/apache/beam/issues/22651 + dependsOn(":sdks:python:test-suites:dataflow:py38:inferencePostCommitIT") } tasks.register("python39PostCommit") { @@ -334,7 +335,6 @@ tasks.register("python39PostCommit") { dependsOn(":sdks:python:test-suites:direct:py39:hdfsIntegrationTest") dependsOn(":sdks:python:test-suites:portable:py39:postCommitPy39") dependsOn(":sdks:python:test-suites:direct:py39:inferencePostCommitIT") - dependsOn(":sdks:python:test-suites:dataflow:py39:inferencePostCommitIT") } task("python37SickbayPostCommit") { diff --git a/sdks/python/test-suites/dataflow/common.gradle b/sdks/python/test-suites/dataflow/common.gradle index f26cec57b6ac..70284d42d35e 100644 --- a/sdks/python/test-suites/dataflow/common.gradle +++ b/sdks/python/test-suites/dataflow/common.gradle @@ -391,6 +391,9 @@ def tensorRTTests = tasks.create("tensorRTtests") { } // add all RunInference E2E tests that run on DataflowRunner +// As of now, this test suite is enable in py38 suite as the base NVIDIA image used for Tensor RT +// contains Python 3.8. +// TODO: https://github.com/apache/beam/issues/22651 project.tasks.register("inferencePostCommitIT") { dependsOn = [ 'tensorRTtests',