Represent a collection of device filters for the remote workers in cluster.
View aliases
Compat aliases for migration
See Migration guide for more details.
tf.config.experimental.ClusterDeviceFilters()
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'])
tf.config.experimental_connect_to_cluster(cluster_def,
cluster_device_filters=cdf)
The device filters can be partically specified. For remote tasks that do not have device filters specified, all devices will be visible to them.
Methods
set_device_filters
set_device_filters(
job_name, task_index, device_filters
)
Set the device filters for given job name and task id.