tf.contrib.cluster_resolver.TFConfigClusterResolver

Class TFConfigClusterResolver

Inherits From: ClusterResolver

Aliases:

  • Class tf.contrib.cluster_resolver.TFConfigClusterResolver
  • Class tf.contrib.cluster_resolver.python.training.TFConfigClusterResolver

Defined in tensorflow/python/distribute/cluster_resolver/tfconfig_cluster_resolver.py.

Implementation of a ClusterResolver which reads the TF_CONFIG EnvVar.

__init__

__init__(
    task_type=None,
    task_index=None,
    rpc_layer=None,
    environment=None
)

Creates a new TFConfigClusterResolver.

Args:

  • task_type: (String, optional) Overrides the task type specified in the TF_CONFIG environment variable.
  • task_index: (Integer, optional) Overrides the task index specified in the TF_CONFIG environment variable.
  • rpc_layer: (String, optional) Overrides the rpc layer TensorFlow uses.
  • environment: (String, optional) Overrides the environment TensorFlow operates in.

Properties

environment

Returns the current environment which TensorFlow is running in.

rpc_layer

task_index

task_type

Methods

cluster_spec

cluster_spec()

Returns a ClusterSpec based on the TF_CONFIG environment variable.

Returns:

A ClusterSpec with information from the TF_CONFIG environment variable.

master

master(
    task_type=None,
    task_index=None,
    rpc_layer=None
)

Returns the master address to use when creating a TensorFlow session.

Args:

  • task_type: (String, optional) Overrides and sets the task_type of the master.
  • task_index: (Integer, optional) Overrides and sets the task id of the master.
  • rpc_layer: (String, optional) Overrides and sets the protocol over which TensorFlow nodes communicate with each other.

Returns:

The address of the master.

Raises:

  • RuntimeError: If the task_type or task_id is not specified and the TF_CONFIG environment variable does not contain a task section.

num_accelerators

num_accelerators(
    task_type=None,
    task_index=None,
    accelerator_type='GPU',
    config_proto=None
)

Returns the number of accelerator cores per worker.

This returns the number of accelerator cores (such as GPUs and TPUs) available per worker. If workers only has CPU cores available, then this should return 0. This method will query the master for this information if it is not otherwise known.

Optionally, we allow callers to specify the task_type, task_index, and rpc_layer, if they want to target a specific TensorFlow process to query the number of accelerators. This is to support heterogenous environments, where the number of accelerators cores per host is different.

Args:

  • task_type: (Optional) The type of the TensorFlow task of the machine we want to query.
  • task_index: (Optional) The index of the TensorFlow task of the machine we want to query.
  • accelerator_type: (Optional) The type of accelerator we are trying to query (defaults to 'GPU').
  • config_proto: (Optional) Configuration for starting a new session to query how many accelerator cores it has.