tf.distribute.cluster_resolver.TFConfigClusterResolver
Stay organized with collections
Save and categorize content based on your preferences.
Implementation of a ClusterResolver which reads the TF_CONFIG EnvVar.
Inherits From: ClusterResolver
tf.distribute.cluster_resolver.TFConfigClusterResolver(
task_type=None, task_id=None, rpc_layer=None, environment=None
)
This is an implementation of cluster resolvers when using TF_CONFIG to set
information about the cluster. The cluster spec returned will be
initialized from the TF_CONFIG environment variable.
Args |
task_type
|
(String, optional) Overrides the task type specified in the
TF_CONFIG environment variable.
|
task_id
|
(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.
|
Attributes |
environment
|
Returns the current environment which TensorFlow is running in.
There are two possible return values, "google" (when TensorFlow is running
in a Google-internal environment) or an empty string (when TensorFlow is
running elsewhere).
If you are implementing a ClusterResolver that works in both the Google
environment and the open-source world (for instance, a TPU ClusterResolver
or similar), you will have to return the appropriate string depending on the
environment, which you will have to detect.
Otherwise, if you are implementing a ClusterResolver that will only work
in open-source TensorFlow, you do not need to implement this property.
|
rpc_layer
|
|
task_id
|
|
task_type
|
|
Methods
cluster_spec
View source
cluster_spec()
Returns a ClusterSpec based on the TF_CONFIG environment variable.
Returns |
A ClusterSpec with information from the TF_CONFIG environment variable.
|
master
View source
master(
task_type=None, task_id=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_id
|
(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
View source
num_accelerators(
task_type=None, task_id=None, 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.
Optionally, we allow callers to specify the task_type, and task_id, for
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_id
|
(Optional) The index of the TensorFlow task of the machine we
want to query.
|
config_proto
|
(Optional) Configuration for starting a new session to
query how many accelerator cores it has.
|
Returns |
A map of accelerator types to number of cores.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2020-10-01 UTC."],[],[],null,["# tf.distribute.cluster_resolver.TFConfigClusterResolver\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 1 version](/versions/r1.15/api_docs/python/tf/distribute/cluster_resolver/TFConfigClusterResolver) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/distribute/cluster_resolver/tfconfig_cluster_resolver.py#L52-L177) |\n\nImplementation of a ClusterResolver which reads the TF_CONFIG EnvVar.\n\nInherits From: [`ClusterResolver`](../../../tf/distribute/cluster_resolver/ClusterResolver)\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.distribute.cluster_resolver.TFConfigClusterResolver`](/api_docs/python/tf/distribute/cluster_resolver/TFConfigClusterResolver)\n\n\u003cbr /\u003e\n\n tf.distribute.cluster_resolver.TFConfigClusterResolver(\n task_type=None, task_id=None, rpc_layer=None, environment=None\n )\n\nThis is an implementation of cluster resolvers when using TF_CONFIG to set\ninformation about the cluster. The cluster spec returned will be\ninitialized from the TF_CONFIG environment variable.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------------|-----------------------------------------------------------------------------------------------|\n| `task_type` | (String, optional) Overrides the task type specified in the TF_CONFIG environment variable. |\n| `task_id` | (Integer, optional) Overrides the task index specified in the TF_CONFIG environment variable. |\n| `rpc_layer` | (String, optional) Overrides the rpc layer TensorFlow uses. |\n| `environment` | (String, optional) Overrides the environment TensorFlow operates in. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `environment` | Returns the current environment which TensorFlow is running in. \u003cbr /\u003e There are two possible return values, \"google\" (when TensorFlow is running in a Google-internal environment) or an empty string (when TensorFlow is running elsewhere). If you are implementing a ClusterResolver that works in both the Google environment and the open-source world (for instance, a TPU ClusterResolver or similar), you will have to return the appropriate string depending on the environment, which you will have to detect. Otherwise, if you are implementing a ClusterResolver that will only work in open-source TensorFlow, you do not need to implement this property. |\n| `rpc_layer` | \u003cbr /\u003e \u003cbr /\u003e |\n| `task_id` | \u003cbr /\u003e \u003cbr /\u003e |\n| `task_type` | \u003cbr /\u003e \u003cbr /\u003e |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `cluster_spec`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/distribute/cluster_resolver/tfconfig_cluster_resolver.py#L129-L138) \n\n cluster_spec()\n\nReturns a ClusterSpec based on the TF_CONFIG environment variable.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| A ClusterSpec with information from the TF_CONFIG environment variable. ||\n\n\u003cbr /\u003e\n\n### `master`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/distribute/cluster_resolver/tfconfig_cluster_resolver.py#L140-L177) \n\n master(\n task_type=None, task_id=None, rpc_layer=None\n )\n\nReturns the master address to use when creating a TensorFlow session.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|-------------|-------------------------------------------------------------------------------------------------------------|\n| `task_type` | (String, optional) Overrides and sets the task_type of the master. |\n| `task_id` | (Integer, optional) Overrides and sets the task id of the master. |\n| `rpc_layer` | (String, optional) Overrides and sets the protocol over which TensorFlow nodes communicate with each other. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| The address of the master. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ||\n|----------------|------------------------------------------------------------------------------------------------------------------------|\n| `RuntimeError` | If the task_type or task_id is not specified and the `TF_CONFIG` environment variable does not contain a task section. |\n\n\u003cbr /\u003e\n\n### `num_accelerators`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/distribute/cluster_resolver/tfconfig_cluster_resolver.py#L120-L127) \n\n num_accelerators(\n task_type=None, task_id=None, config_proto=None\n )\n\nReturns the number of accelerator cores per worker.\n\nThis returns the number of accelerator cores (such as GPUs and TPUs)\navailable per worker.\n\nOptionally, we allow callers to specify the task_type, and task_id, for\nif they want to target a specific TensorFlow process to query\nthe number of accelerators. This is to support heterogenous environments,\nwhere the number of accelerators cores per host is different.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|----------------|-------------------------------------------------------------------------------------------------|\n| `task_type` | (Optional) The type of the TensorFlow task of the machine we want to query. |\n| `task_id` | (Optional) The index of the TensorFlow task of the machine we want to query. |\n| `config_proto` | (Optional) Configuration for starting a new session to query how many accelerator cores it has. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| A map of accelerator types to number of cores. ||\n\n\u003cbr /\u003e"]]