Allow setting a server_def on the context. When a server def is replaced, it effectively clears a bunch of caches within the context. If you attempt to use a tensor object that was pointing to a tensor on the remote device, it will raise an error. Args: server_def: A tensorfl
(self, server_def, keep_alive_secs=600)
| 514 | pywrap_tensorflow.TFE_ClearScalarCache() |
| 515 | |
| 516 | def set_server_def(self, server_def, keep_alive_secs=600): |
| 517 | """Allow setting a server_def on the context. |
| 518 | |
| 519 | When a server def is replaced, it effectively clears a bunch of caches |
| 520 | within the context. If you attempt to use a tensor object that was pointing |
| 521 | to a tensor on the remote device, it will raise an error. |
| 522 | |
| 523 | Args: |
| 524 | server_def: A tensorflow::ServerDef proto. |
| 525 | Enables execution on remote devices. |
| 526 | keep_alive_secs: Num. seconds after which the remote end will hang up. |
| 527 | As long as the client is still alive, the server state for the context |
| 528 | will be kept alive. If the client is killed (or there is some failure), |
| 529 | the server will clean up its context keep_alive_secs after the final RPC |
| 530 | it receives. |
| 531 | |
| 532 | Raises: |
| 533 | ValueError: if server_def is None. |
| 534 | """ |
| 535 | if not server_def: |
| 536 | raise ValueError("server_def is None.") |
| 537 | |
| 538 | self._server_def = server_def |
| 539 | |
| 540 | if self._context_handle: |
| 541 | server_def_str = server_def.SerializeToString() |
| 542 | pywrap_tensorflow.TFE_ContextSetServerDef(self._context_handle, |
| 543 | keep_alive_secs, server_def_str) |
| 544 | self._initialize_logical_devices() |
| 545 | |
| 546 | # Clear all the caches in case there are remote tensors in them. |
| 547 | self._clear_caches() |
| 548 | |
| 549 | def enable_collective_ops(self, server_def): |
| 550 | """Enable distributed collective ops with an appropriate server_def. |