Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check parameters before creating gRPC server #20549

Merged
merged 4 commits into from
Aug 10, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 27 additions & 20 deletions tensorflow/core/distributed_runtime/rpc/grpc_server_lib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,27 +120,9 @@ 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.");
}
// Check parameters before DeviceFactory::AddDevices,
// otherwise if 'task_index=-1' the program will abort.

// Look up the port that has been requested for this task in `server_def_`.
int requested_port = -1;
Expand Down Expand Up @@ -169,6 +151,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
Expand Down