MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / create_local_cluster

Function create_local_cluster

tensorflow/python/framework/test_util.py:3003–3089  ·  view source on GitHub ↗

Create and start local servers and return the associated `Server` objects. "PS" stands for "parameter server": a task responsible for storing and updating the model's parameters. Other tasks send updates to these parameters as they work on optimizing the parameters. This particular division o

(num_workers,
                         num_ps,
                         protocol="grpc",
                         worker_config=None,
                         ps_config=None)

Source from the content-addressed store, hash-verified

3001
3002@tf_export("test.create_local_cluster")
3003def create_local_cluster(num_workers,
3004 num_ps,
3005 protocol="grpc",
3006 worker_config=None,
3007 ps_config=None):
3008 """Create and start local servers and return the associated `Server` objects.
3009
3010 "PS" stands for "parameter server": a task responsible for storing and
3011 updating the model's parameters. Other tasks send updates to these parameters
3012 as they work on optimizing the parameters. This particular division of labor
3013 between tasks is not required, but is common for distributed training.
3014
3015 Read more at https://www.tensorflow.org/guide/extend/architecture
3016
3017 ![components](https://www.tensorflow.org/images/diag1.svg "components")
3018
3019
3020 Figure illustrates the interaction of these components.
3021 "/job:worker/task:0" and "/job:ps/task:0" are both tasks with worker services.
3022
3023
3024 Example:
3025 ```python
3026 workers, _ = tf.test.create_local_cluster(num_workers=2, num_ps=2)
3027
3028 worker_sessions = [tf.compat.v1.Session(w.target) for w in workers]
3029
3030 with tf.device("/job:ps/task:0"):
3031 ...
3032 with tf.device("/job:ps/task:1"):
3033 ...
3034 with tf.device("/job:worker/task:0"):
3035 ...
3036 with tf.device("/job:worker/task:1"):
3037 ...
3038
3039 worker_sessions[0].run(...)
3040 ```
3041
3042 Args:
3043 num_workers: Number of worker servers to start.
3044 num_ps: Number of PS servers to start.
3045 protocol: Communication protocol. Allowed values are documented in the
3046 documentation of `tf.distribute.Server`.
3047 worker_config: (optional) `tf.ConfigProto` to initialize workers. Can be
3048 used to instantiate multiple devices etc.
3049 ps_config: (optional) `tf.ConfigProto` to initialize PS servers.
3050
3051 Returns:
3052 A tuple `(worker_servers, ps_servers)`. `worker_servers` is a list
3053 of `num_workers` objects of type `tf.distribute.Server` (all running
3054 locally);
3055 and `ps_servers` is a list of `num_ps` objects of similar type.
3056
3057 Raises:
3058 ImportError: if portpicker module was not found at load time
3059 """
3060 if _portpicker_import_error:

Callers 2

test2WorkersMethod · 0.90
test3Workers1BackupMethod · 0.90

Calls 2

ServerMethod · 0.80
rangeFunction · 0.50

Tested by

no test coverage detected