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

Function connect_to_remote_host

tensorflow/python/eager/remote.py:37–73  ·  view source on GitHub ↗

Connects to a single machine to enable remote execution on it. Will make devices on the remote host available to use. Note that calling this more than once will work, but will invalidate any tensor handles on the old remote devices. Using the default job_name of worker, you can schedule op

(remote_host=None, job_name="worker")

Source from the content-addressed store, hash-verified

35
36@tf_export("config.experimental_connect_to_host")
37def connect_to_remote_host(remote_host=None, job_name="worker"):
38 """Connects to a single machine to enable remote execution on it.
39
40 Will make devices on the remote host available to use. Note that calling this
41 more than once will work, but will invalidate any tensor handles on the old
42 remote devices.
43
44 Using the default job_name of worker, you can schedule ops to run remotely as
45 follows:
46 ```python
47 # Enable eager execution, and connect to the remote host.
48 tf.compat.v1.enable_eager_execution()
49 tf.contrib.eager.connect_to_remote_host("exampleaddr.com:9876")
50
51 with ops.device("job:worker/replica:0/task:1/device:CPU:0"):
52 # The following tensors should be resident on the remote device, and the op
53 # will also execute remotely.
54 x1 = array_ops.ones([2, 2])
55 x2 = array_ops.ones([2, 2])
56 y = math_ops.matmul(x1, x2)
57 ```
58
59 Args:
60 remote_host: a single or a list the remote server addr in host-port format.
61 job_name: The job name under which the new server will be accessible.
62
63 Raises:
64 ValueError: if remote_host is None.
65 """
66 if not remote_host:
67 raise ValueError("Must provide at least one remote_host")
68
69 remote_hosts = nest.flatten(remote_host)
70 cluster_spec = server_lib.ClusterSpec(
71 {job_name: [_strip_prefix(host, _GRPC_PREFIX) for host in remote_hosts]})
72
73 connect_to_cluster(cluster_spec)
74
75
76@tf_export("config.experimental_connect_to_cluster")

Callers

nothing calls this directly

Calls 3

connect_to_clusterFunction · 0.85
_strip_prefixFunction · 0.70
flattenMethod · 0.45

Tested by

no test coverage detected