diff --git a/config/buildspec_tensorflow_2_4.yml b/config/buildspec_tensorflow_2_4.yml new file mode 100644 index 000000000..5bac6588e --- /dev/null +++ b/config/buildspec_tensorflow_2_4.yml @@ -0,0 +1,62 @@ +# Build Spec for AWS CodeBuild CI TF 2.4.x CPU and GPU Containers +# Containers Used: + # Note: The public DLC is not yet available so this buildspec is currently consuming a custom built container + +version: 0.2 +env: + variables: + run_pytest_pytorch: "disable" + run_pytest_mxnet: "disable" + run_pytest_tensorflow: "disable" + run_pytest_tensorflow2: "enable" + run_pytest_xgboost: "disable" + run_pytest_profiler: "enable" + run_integration_pytest_pytorch: "disable" + run_integration_pytest_mxnet: "disable" + run_integration_pytest_tensorflow: "disable" + run_integration_pytest_tensorflow2: "enable" + run_integration_pytest_xgboost: "disable" + # below needs to be enabled + zero_code_change_test: "enable" + # set code coverage flag + code_coverage_smdebug: "true" +phases: + install: + commands: + - . config/change_branch.sh + - su && apt-get update + - apt-get install sudo -qq -o=Dpkg::Use-Pty=0 # silence output: https://askubuntu.com/a/668859/724247 + - sudo apt-get update -qq -o=Dpkg::Use-Pty=0 + - sudo apt-get install unzip -qq -o=Dpkg::Use-Pty=0 + - cd $CODEBUILD_SRC_DIR && chmod +x config/protoc_downloader.sh && ./config/protoc_downloader.sh + - pip install --upgrade pip==19.3.1 + - pip install -q matplotlib==3.3.1 seaborn==0.10.1 nbconvert==5.6.1 papermill==2.1.2 jupyter==1.0.0 scipy==1.5.2 scikit-learn==0.23.2 bokeh==2.2.3 + - if [ "$run_pytest_xgboost" = "enable" ]; then pip install --upgrade pyYaml==5.1; else pip install -q pyYaml; fi + - pip install -q pytest wheel pytest-html pre-commit awscli pytest-cov + + pre_build: + commands: + - cd $CODEBUILD_SRC_DIR && pre-commit install && pre-commit run --all-files + + build: + commands: + - cd $CODEBUILD_SRC_DIR && python setup.py bdist_wheel --universal + # We do not need to force install smdebug-rules. The container used for PR builds do not have smdebug rules binary. + # Force installing rules binary attempts to re-install ipython-genutils which fails on PyTorch Ubuntu 16.04 containers. + - cd $RULES_CODEBUILD_SRC_DIR && python setup.py bdist_wheel --universal + - if [ "$run_pytest_xgboost" = "enable" ]; then pip install --force-reinstall $RULES_CODEBUILD_SRC_DIR/dist/*.whl; else pip install $RULES_CODEBUILD_SRC_DIR/dist/*.whl; fi + - cd $CODEBUILD_SRC_DIR && pip install --force-reinstall dist/*.whl && cd .. + - cd $CODEBUILD_SRC_DIR && chmod +x config/tests.sh && PYTHONPATH=. && ./config/tests.sh && mkdir -p upload/$CURRENT_COMMIT_PATH/wheels && cp ./dist/*.whl upload/$CURRENT_COMMIT_PATH/wheels && cd .. + - pip show smdebug + - pip show smdebug_rules + - echo 'Uploading Coverage to CodeCov' + - bash $CODEBUILD_SRC_DIR/config/codecov.sh + - cd $RULES_CODEBUILD_SRC_DIR && chmod +x config/tests.sh && PYTHONPATH=. && mkdir -p upload/$CURRENT_COMMIT_PATH/wheels && ./config/tests.sh && cp ./dist/*.whl upload/$CURRENT_COMMIT_PATH/wheels && cd .. + + post_build: + commands: + - . $CODEBUILD_SRC_DIR/config/upload_on_end.sh + - rm -rf $CODEBUILD_SRC_DIR/upload/$CURRENT_COMMIT_PATH + - rm -rf $RULES_CODEBUILD_SRC_DIR/upload/$CURRENT_COMMIT_PATH + - if [ "$CODEBUILD_BUILD_SUCCEEDING" -eq 0 ]; then echo "ERROR BUILD FAILED " && exit 1 ; fi + - if [ "$CODEBUILD_BUILD_SUCCEEDING" -eq 1 ]; then echo "INFO BUILD SUCCEEDED !!! " ; fi diff --git a/smdebug/tensorflow/utils.py b/smdebug/tensorflow/utils.py index c49f86361..af9a0e901 100644 --- a/smdebug/tensorflow/utils.py +++ b/smdebug/tensorflow/utils.py @@ -428,4 +428,5 @@ def is_tf_version_greater_than_2_4_x(): def is_profiler_supported_for_tf_version(): - return is_tf_version_2_2_x() or is_tf_version_2_3_x() + # Profiler Support Added For TF Versions 2.2.0 And Greater + return version.parse("2.2.0") <= TF_VERSION diff --git a/tests/tensorflow2/test_estimator.py b/tests/tensorflow2/test_estimator.py index 92f8d732e..efb13a486 100644 --- a/tests/tensorflow2/test_estimator.py +++ b/tests/tensorflow2/test_estimator.py @@ -2,6 +2,7 @@ # Third Party import pytest import tensorflow.compat.v2 as tf +from tests.tensorflow2.utils import is_tf_version_greater_than_2_4_x from tests.zero_code_change.tf_utils import get_estimator, get_input_fns # First Party @@ -71,10 +72,13 @@ def test_linear_classifier(out_dir, tf_eager_mode, saveall): # vanilla TF 2.2: all = 214, loss = 2, weights = 1, gradients = 0, biases = 12, optimizer variables = 0, metrics = 0, others = 199 # AWS-TF 2.2: all = 219, loss = 2, weights = 1, gradients = 2, biases = 12, optimizer variables = 5, metrics = 0, others = 197 # AWS-TF 2.1: all = 226, loss = 2, weights = 1, gradients = 2, biases = 12, optimizer variables = 5, metrics = 0, others = 204 + # AWS-TF 2.4: all = 229, loss = 2, weights = 1, gradients = 2, biases = 16, optimizer variables = 5, metrics = 0, others = 197 assert len(tnames) >= 2 + 1 + 12 assert len(trial.tensor_names(collection=CollectionKeys.LOSSES)) == 2 assert len(trial.tensor_names(collection=CollectionKeys.WEIGHTS)) == 1 - assert len(trial.tensor_names(collection=CollectionKeys.BIASES)) == 12 + assert len(trial.tensor_names(collection=CollectionKeys.BIASES)) == ( + 16 if is_tf_version_greater_than_2_4_x() else 12 + ) assert len(trial.tensor_names(collection=CollectionKeys.GRADIENTS)) >= 0 assert len(trial.tensor_names(collection=CollectionKeys.OPTIMIZER_VARIABLES)) >= 0 else: diff --git a/tests/tensorflow2/utils.py b/tests/tensorflow2/utils.py index 8575a2470..439accee1 100644 --- a/tests/tensorflow2/utils.py +++ b/tests/tensorflow2/utils.py @@ -24,3 +24,7 @@ def is_tf_2_3(): if TF_VERSION == version.parse("2.3.0"): return True return False + + +def is_tf_version_greater_than_2_4_x(): + return version.parse("2.4.0") <= TF_VERSION