Fix a multi-gpu test failure.

The test uses tf.constant as input to all_reduce in pure eager mode, however in eager mode tf.constant always creates host tensors regardless of the enclosing device scope. This leads to NCCL error.

PiperOrigin-RevId: 357252841
Change-Id: Iddaf5f52fe6634ec29dd385a9fa034761f3df91f
This commit is contained in:
Chenkai Kuang 2021-02-12 13:06:24 -08:00 committed by TensorFlower Gardener
parent 8e4ba814c2
commit aa9bd19fe3

View File

@ -131,7 +131,7 @@ class ReplicaCtxAllReduceTest(test.TestCase, parameterized.TestCase):
def fn():
def replica_fn():
value = constant_op.constant(1.0)
value = array_ops.identity(1.0)
reduced = strategy.extended._replica_ctx_all_reduce('SUM', value)
return reduced
@ -152,7 +152,7 @@ class ReplicaCtxAllReduceTest(test.TestCase, parameterized.TestCase):
def fn():
def replica_fn():
value = (constant_op.constant(1.0), constant_op.constant(2.0))
value = (array_ops.identity(1.0), array_ops.identity(1.0))
reduced = strategy.extended._replica_ctx_all_reduce('SUM', value)
return reduced