diff options
author | naurril <naurril@gmail.com> | 2018-07-05 00:49:37 +0800 |
---|---|---|
committer | naurril <naurril@gmail.com> | 2018-07-05 00:49:37 +0800 |
commit | 38e56744327f5090585179554d0df21fb52515a6 (patch) | |
tree | 9d17819d840bffbc1891e091a020c04116fdbb63 /tensorflow/core/distributed_runtime | |
parent | 6dbc8eea17d275af07ae91c6b092a07885e2db84 (diff) |
check parameters before init GrpcServer
Diffstat (limited to 'tensorflow/core/distributed_runtime')
-rw-r--r-- | tensorflow/core/distributed_runtime/rpc/grpc_server_lib.cc | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/tensorflow/core/distributed_runtime/rpc/grpc_server_lib.cc b/tensorflow/core/distributed_runtime/rpc/grpc_server_lib.cc index 2c833d11a9..7987fdbcc0 100644 --- a/tensorflow/core/distributed_runtime/rpc/grpc_server_lib.cc +++ b/tensorflow/core/distributed_runtime/rpc/grpc_server_lib.cc @@ -120,27 +120,6 @@ Status GrpcServer::Init( master_env_.env = env_; worker_env_.env = env_; - SessionOptions sess_opts; - ConfigProto config = server_def_.default_session_config(); - sess_opts.config = config; - - // Configure shared devices between master and worker. - string name_prefix = - strings::StrCat("/job:", server_def_.job_name(), "/replica:0", - "/task:", server_def_.task_index()); - TF_RETURN_IF_ERROR(DeviceFactory::AddDevices(sess_opts, name_prefix, - &master_env_.local_devices)); - worker_env_.local_devices = master_env_.local_devices; - worker_env_.device_mgr = new DeviceMgr(worker_env_.local_devices); - worker_env_.rendezvous_mgr = rendezvous_mgr_func == nullptr - ? new RpcRendezvousMgr(&worker_env_) - : rendezvous_mgr_func(&worker_env_); - string unused; - string default_worker_name; - if (!DeviceNameUtils::SplitDeviceName(master_env_.local_devices[0]->name(), - &default_worker_name, &unused)) { - return errors::Internal("Could not parse worker name."); - } // Look up the port that has been requested for this task in `server_def_`. int requested_port = -1; @@ -169,6 +148,31 @@ Status GrpcServer::Init( "\" was not defined in cluster"); } + + SessionOptions sess_opts; + ConfigProto config = server_def_.default_session_config(); + sess_opts.config = config; + + // Configure shared devices between master and worker. + string name_prefix = + strings::StrCat("/job:", server_def_.job_name(), "/replica:0", + "/task:", server_def_.task_index()); + TF_RETURN_IF_ERROR(DeviceFactory::AddDevices(sess_opts, name_prefix, + &master_env_.local_devices)); + worker_env_.local_devices = master_env_.local_devices; + worker_env_.device_mgr = new DeviceMgr(worker_env_.local_devices); + worker_env_.rendezvous_mgr = rendezvous_mgr_func == nullptr + ? new RpcRendezvousMgr(&worker_env_) + : rendezvous_mgr_func(&worker_env_); + string unused; + string default_worker_name; + if (!DeviceNameUtils::SplitDeviceName(master_env_.local_devices[0]->name(), + &default_worker_name, &unused)) { + return errors::Internal("Could not parse worker name."); + } + + + // N.B. The order of initialization here is intricate, because we // wish to allow `requested_port == 0` (for choosing any port, // mostly for testing). Therefore, the construction of the channel |