Skip to content

Commit

Permalink
set tf2.6.0 as a switching point between keras and tensorflow.keras
Browse files Browse the repository at this point in the history
  • Loading branch information
chongxiaoc committed Feb 19, 2022
1 parent a7849c7 commit 414f744
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 19 deletions.
9 changes: 4 additions & 5 deletions Dockerfile.test.cpu
Expand Up @@ -145,21 +145,20 @@ RUN if [[ ${MPI_KIND} != "None" ]]; then \
fi

# Install TensorFlow and Keras (releases).
# Pin h5py only for tensorflow<2.5: https://github.com/h5py/h5py/issues/1732
# Pin scipy!=1.4.0: https://github.com/scipy/scipy/issues/11237
RUN if [[ ${TENSORFLOW_PACKAGE} != "tf-nightly" ]]; then \
pip install --no-cache-dir ${TENSORFLOW_PACKAGE}; \
if [[ ${KERAS_PACKAGE} != "None" ]]; then \
if [[ ${TENSORFLOW_PACKAGE} == tensorflow*==1.* ]] || [[ ${TENSORFLOW_PACKAGE} == tensorflow*==2.[012345].* ]]; then \
h5py="h5py<3"; \
fi; \
pip uninstall -y keras-nightly; \
pip install --no-cache-dir ${KERAS_PACKAGE} ${h5py:-} "scipy!=1.4.0" "pandas<1.1.0"; \
pip install --no-cache-dir ${KERAS_PACKAGE} "scipy!=1.4.0" "pandas<1.1.0"; \
fi; \
mkdir -p ~/.keras; \
python -c "import tensorflow as tf; tf.keras.datasets.mnist.load_data()"; \
fi

# Pin h5py < 3 for tensorflow: https://github.com/tensorflow/tensorflow/issues/44467
RUN pip install 'h5py<3.0' --force-reinstall

# Install PyTorch (releases).
# Pin Pillow<7.0 for torchvision < 0.5.0: https://github.com/pytorch/vision/issues/1718
# Pin Pillow!=8.3.0 for torchvision: https://github.com/pytorch/vision/issues/4146
Expand Down
9 changes: 4 additions & 5 deletions Dockerfile.test.gpu
Expand Up @@ -113,23 +113,22 @@ RUN if [[ ${MPI_KIND} != "None" ]]; then \
fi

# Install TensorFlow and Keras (releases).
# Pin h5py only for tensorflow<2.5: https://github.com/h5py/h5py/issues/1732
# Pin scipy!=1.4.0: https://github.com/scipy/scipy/issues/11237
RUN if [[ ${TENSORFLOW_PACKAGE} != "tf-nightly-gpu" ]]; then \
pip install --no-cache-dir ${TENSORFLOW_PACKAGE}; \
if [[ ${KERAS_PACKAGE} != "None" ]]; then \
if [[ ${TENSORFLOW_PACKAGE} == tensorflow*==1.* ]] || [[ ${TENSORFLOW_PACKAGE} == tensorflow*==2.[012345].* ]]; then \
h5py="h5py<3"; \
fi; \
pip uninstall -y keras-nightly; \
pip install --no-cache-dir ${KERAS_PACKAGE} ${h5py:-} "scipy!=1.4.0" "pandas<1.1.0"; \
pip install --no-cache-dir ${KERAS_PACKAGE} "scipy!=1.4.0" "pandas<1.1.0"; \
fi; \
mkdir -p ~/.keras; \
ldconfig /usr/local/cuda/targets/x86_64-linux/lib/stubs; \
python -c "import tensorflow as tf; tf.keras.datasets.mnist.load_data()"; \
ldconfig; \
fi

# Pin h5py < 3 for tensorflow: https://github.com/tensorflow/tensorflow/issues/44467
RUN pip install 'h5py<3.0' --force-reinstall

# Install PyTorch (releases).
# Pin Pillow<7.0 for torchvision < 0.5.0: https://github.com/pytorch/vision/issues/1718
# Pin Pillow!=8.3.0 for torchvision: https://github.com/pytorch/vision/issues/4146
Expand Down
2 changes: 1 addition & 1 deletion horovod/spark/keras/tensorflow.py
Expand Up @@ -19,7 +19,7 @@

from horovod.common.util import is_version_greater_equal_than

if is_version_greater_equal_than(tf.__version__, "2.5.0"):
if is_version_greater_equal_than(tf.__version__, "2.6.0"):
from keras import backend as K
from keras import optimizers
else:
Expand Down
2 changes: 1 addition & 1 deletion horovod/tensorflow/keras/__init__.py
Expand Up @@ -22,7 +22,7 @@

from horovod.common.util import is_version_greater_equal_than

if is_version_greater_equal_than(tf.__version__, "2.5.0"):
if is_version_greater_equal_than(tf.__version__, "2.6.0"):
from keras import backend as K
else:
from tensorflow.python.keras import backend as K
Expand Down
2 changes: 1 addition & 1 deletion horovod/tensorflow/keras/callbacks.py
Expand Up @@ -19,7 +19,7 @@

from horovod.common.util import is_version_greater_equal_than

if is_version_greater_equal_than(tf.__version__, "2.5.0"):
if is_version_greater_equal_than(tf.__version__, "2.6.0"):
from keras import backend as K
else:
from tensorflow.python.keras import backend as K
Expand Down
1 change: 0 additions & 1 deletion test/integration/test_spark.py
Expand Up @@ -1665,7 +1665,6 @@ def test_spark_task_service_execute_command(self):
file = os.path.sep.join([d, 'command_executed'])
self.do_test_spark_task_service_executes_command(client, file)

@mock.patch('horovod.runner.common.util.safe_shell_exec.GRACEFUL_TERMINATION_TIME_S', 0.5)
def test_spark_task_service_abort_command(self):
with spark_task_service(index=0) as (service, client, _):
with tempdir() as d:
Expand Down
3 changes: 0 additions & 3 deletions test/integration/test_spark_keras.py
Expand Up @@ -72,9 +72,6 @@ def fit(model, train_data, val_data, steps_per_epoch, validation_steps, callback
return fit


#PR3099 [https://github.com/horovod/horovod/pull/3099] doesn't fix
#Tensorflow>=2.6.0 tests
@pytest.mark.skipif(LooseVersion(tf.__version__) >= LooseVersion('2.6.0'), reason='TensorFlow>=2.6.0 tests')
class SparkKerasTests(tf.test.TestCase):
def __init__(self, *args, **kwargs):
super(SparkKerasTests, self).__init__(*args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test_tensorflow2_keras.py
Expand Up @@ -29,7 +29,7 @@

from horovod.common.util import is_version_greater_equal_than

if is_version_greater_equal_than(tf.__version__, "2.5.0"):
if is_version_greater_equal_than(tf.__version__, "2.6.0"):
from keras.optimizer_v2 import optimizer_v2
else:
from tensorflow.python.keras.optimizer_v2 import optimizer_v2
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test_tensorflow_keras.py
Expand Up @@ -28,7 +28,7 @@

from horovod.common.util import is_version_greater_equal_than

if is_version_greater_equal_than(tf.__version__, "2.5.0"):
if is_version_greater_equal_than(tf.__version__, "2.6.0"):
from keras import backend as K
from keras.optimizer_v2 import optimizer_v2
else:
Expand Down

0 comments on commit 414f744

Please sign in to comment.