| 634 | } |
| 635 | |
| 636 | Status EagerContext::InitializeRemoteMaster( |
| 637 | std::unique_ptr<ServerInterface> server, WorkerEnv* worker_env, |
| 638 | std::shared_ptr<WorkerSession> worker_session, |
| 639 | std::unique_ptr<eager::EagerClientCache> remote_eager_workers, |
| 640 | std::unique_ptr<DeviceMgr> remote_device_manager, |
| 641 | const std::vector<string>& remote_contexts, uint64 context_id, |
| 642 | Rendezvous* r, DeviceMgr* local_device_mgr, int keep_alive_secs, |
| 643 | DistributedFunctionLibraryRuntime* cluster_flr, |
| 644 | std::unique_ptr<eager::RemoteMgr, std::function<void(eager::RemoteMgr*)>> |
| 645 | remote_mgr) { |
| 646 | if (context_id == kInvalidContextId) { |
| 647 | return errors::InvalidArgument( |
| 648 | "Failed to initialize remote for master context due to invalid ", |
| 649 | "context id"); |
| 650 | } |
| 651 | |
| 652 | if (!remote_contexts_.empty()) { |
| 653 | CloseRemoteContexts(); |
| 654 | } |
| 655 | |
| 656 | mutex_lock l(remote_state_mu_); |
| 657 | is_master_ = true; |
| 658 | context_id_ = context_id; |
| 659 | remote_contexts_ = remote_contexts; |
| 660 | |
| 661 | use_send_tensor_rpc_ = |
| 662 | ReadBoolFromEnvVar("TF_EAGER_REMOTE_USE_SEND_TENSOR_RPC", false); |
| 663 | |
| 664 | local_unowned_device_manager_ = local_device_mgr; |
| 665 | local_device_manager_ = nullptr; |
| 666 | pflr_.reset(new ProcessFunctionLibraryRuntime( |
| 667 | local_unowned_device_manager_, env_, TF_GRAPH_DEF_VERSION, &func_lib_def_, |
| 668 | {}, thread_pool_.get(), cluster_flr, custom_kernel_creator_)); |
| 669 | |
| 670 | devices_ = local_unowned_device_manager_->ListDevices(); |
| 671 | devices_map_.clear(); |
| 672 | |
| 673 | if (rendezvous_ != nullptr) rendezvous_->Unref(); |
| 674 | rendezvous_ = r; |
| 675 | |
| 676 | // Memory leak! |
| 677 | if (server_ != nullptr) { |
| 678 | LOG(WARNING) << "Unable to destroy server_ object, so releasing instead. " |
| 679 | "Servers don't support clean shutdown."; |
| 680 | server_.release(); |
| 681 | } |
| 682 | |
| 683 | server_ = std::move(server); |
| 684 | remote_mgr_ = std::move(remote_mgr); |
| 685 | worker_env_ = worker_env; |
| 686 | worker_session_ = worker_session; |
| 687 | remote_eager_workers_ = std::move(remote_eager_workers); |
| 688 | |
| 689 | remote_device_manager_ = std::move(remote_device_manager); |
| 690 | |
| 691 | InitDeviceMapAndAsync(); |
| 692 | |
| 693 | ClearCaches(); |
no test coverage detected