# tf.distribute.experimental.rpc.Server

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.14.0/tensorflow/python/distribute/experimental/rpc/rpc_ops.py#L50-L114) |

A Server base class for accepting RPCs for registered tf.functions.

Functions can be registered on the server and are exposed via RPCs.

## Methods

### `create`

[View source](https://github.com/tensorflow/tensorflow/blob/v2.14.0/tensorflow/python/distribute/experimental/rpc/rpc_ops.py#L57-L91)

    @staticmethod
    create(
        rpc_layer, address
    )

Create TF RPC server at given address.

<br />

<br />

<br />

| Args ||
|---|---|
| `rpc_layer` | Communication layer between client and server. Only "grpc" rpc layer is supported at the moment. |
| `address` | Address where RPC server is hosted. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| An instance of [`tf.distribute.experimental.rpc.Server`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/distribute/experimental/rpc/Server) class. ||

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| A ValueError if rpc_layer other than "grpc" is used. Only GRPC is supported at the moment. ||

<br />

<br />

<br />

<br />

| Example usage ||
|---|---|
| <br /> >>> import portpicker >>> @tf.function(input_signature=[ ...      tf.TensorSpec([], tf.int32), ...      tf.TensorSpec([], tf.int32)]) ... def remote_fn(a, b): ...   return tf.add(a, b) port = portpicker.pick_unused_port() address = "localhost:{}".format(port) server = tf.distribute.experimental.rpc.Server.create("grpc", address) server.register("addition", remote_fn) server.start() <br /> ||

<br />

### `register`

[View source](https://github.com/tensorflow/tensorflow/blob/v2.14.0/tensorflow/python/distribute/experimental/rpc/rpc_ops.py#L93-L106)

    register(
        method_name: str,
        func: Union[def_function.Function, tf_function.ConcreteFunction]
    )

Method for registering tf.function on server.

Registered methods can be invoked remotely from clients.

<br />

<br />

<br />

| Args ||
|---|---|
| `method_name` | Name of the tf.function. Clients use this method_name to make RPCs. |
| `func` | A [`tf.function`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/function) or ConcreteFunction to register. |

<br />

### `start`

[View source](https://github.com/tensorflow/tensorflow/blob/v2.14.0/tensorflow/python/distribute/experimental/rpc/rpc_ops.py#L108-L114)

    start()

Starts the RPC server on provided address.

Server listens for new requests from client, once it is started.