/TensorFlow 2.4


Represent a collection of device filters for the remote workers in cluster.

Note: this is an experimental API and subject to changes.

Set device filters for selective jobs and tasks. For each remote worker, the device filters are a list of strings. When any filters are present, the remote worker will ignore all devices which do not match any of its filters. Each filter can be partially specified, e.g. "/job:ps", "/job:worker/replica:3", etc. Note that a device is always visible to the worker it is located on.

For example, to set the device filters for a parameter server cluster:

cdf = tf.config.experimental.ClusterDeviceFilters()
for i in range(num_workers):
  cdf.set_device_filters('worker', i, ['/job:ps'])
for i in range(num_ps):
  cdf.set_device_filters('ps', i, ['/job:worker'])


The device filters can be partically specified. For remote tasks that do not have device filters specified, all devices will be visible to them.



View source

Set the device filters for given job name and task id.

© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.