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

Class Server

tensorflow/python/training/server_lib.py:100–238  ·  view source on GitHub ↗

An in-process TensorFlow server, for use in distributed training. A `tf.distribute.Server` instance encapsulates a set of devices and a `tf.compat.v1.Session` target that can participate in distributed training. A server belongs to a cluster (specified by a `tf.train.ClusterSpec`), and co

Source from the content-addressed store, hash-verified

98@tf_export("distribute.Server", v1=["distribute.Server", "train.Server"])
99@deprecation.deprecated_endpoints("train.Server")
100class Server(object):
101 """An in-process TensorFlow server, for use in distributed training.
102
103 A `tf.distribute.Server` instance encapsulates a set of devices and a
104 `tf.compat.v1.Session` target that
105 can participate in distributed training. A server belongs to a
106 cluster (specified by a `tf.train.ClusterSpec`), and
107 corresponds to a particular task in a named job. The server can
108 communicate with any other server in the same cluster.
109 """
110
111 def __init__(self,
112 server_or_cluster_def,
113 job_name=None,
114 task_index=None,
115 protocol=None,
116 config=None,
117 start=True):
118 """Creates a new server with the given definition.
119
120 The `job_name`, `task_index`, and `protocol` arguments are optional, and
121 override any information provided in `server_or_cluster_def`.
122
123 Args:
124 server_or_cluster_def: A `tf.train.ServerDef` or `tf.train.ClusterDef`
125 protocol buffer, or a `tf.train.ClusterSpec` object, describing the
126 server to be created and/or the cluster of which it is a member.
127 job_name: (Optional.) Specifies the name of the job of which the server is
128 a member. Defaults to the value in `server_or_cluster_def`, if
129 specified.
130 task_index: (Optional.) Specifies the task index of the server in its job.
131 Defaults to the value in `server_or_cluster_def`, if specified.
132 Otherwise defaults to 0 if the server's job has only one task.
133 protocol: (Optional.) Specifies the protocol to be used by the server.
134 Acceptable values include `"grpc", "grpc+verbs"`. Defaults to the value
135 in `server_or_cluster_def`, if specified. Otherwise defaults to
136 `"grpc"`.
137 config: (Options.) A `tf.compat.v1.ConfigProto` that specifies default
138 configuration options for all sessions that run on this server.
139 start: (Optional.) Boolean, indicating whether to start the server after
140 creating it. Defaults to `True`.
141
142 Raises:
143 tf.errors.OpError: Or one of its subclasses if an error occurs while
144 creating the TensorFlow server.
145 """
146 os.environ['TASK_INDEX'] = str(task_index)
147
148 self._server_def = _make_server_def(server_or_cluster_def, job_name,
149 task_index, protocol, config)
150 self._server = c_api.TF_NewServer(self._server_def.SerializeToString())
151 if start:
152 self.start()
153
154 def __del__(self):
155 try:
156 c_api.TF_ServerStop(self._server)
157 # Clean shutdown of servers is not yet implemented, so

Callers 1

create_local_serverMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected