DjangoPeng
DjangoPeng

Reputation: 23

tensorflow distribute seq2seq stuck forever

I'm trying to start the distributed seq2seq model in Tensorflow. This is the original single-process seq2seq model. I set a cluster(1ps, 3workers) follow the tensorflow distributed tutorial here.

But all workers are stuck forever, and output the same pooling log info:

start running session
I tensorflow/core/common_runtime/gpu/pool_allocator.cc:244] PoolAllocator: After 7623 get requests, put_count=3649 evicted_count=1000 eviction_rate=0.274048 and unsatisfied allocation rate=0.665617
I tensorflow/core/common_runtime/gpu/pool_allocator.cc:256] Raising pool_size_limit_ from 100 to 110

This is the cluster setting of translate.py:

  ps_hosts = ["9.91.9.129:2222"]
  worker_hosts = ["9.91.9.130:2223", "9.91.9.130:2224", "9.91.9.130:2225"]
  #worker_hosts = ["9.91.9.130:2223"]

  cluster = tf.train.ClusterSpec({"ps":ps_hosts, "worker":worker_hosts})
  server = tf.train.Server(cluster,
                            job_name=FLAGS.job_name,
                            task_index=FLAGS.task_index)
  if FLAGS.job_name == "ps":
        server.join()
  elif FLAGS.job_name == "worker":
      # Worker server 
      is_chief = (FLAGS.task_index == 0)      
      gpu_num = FLAGS.task_index
      with tf.Graph().as_default():
        with tf.device(tf.train.replica_device_setter(cluster=cluster,
            worker_device="/job:worker/task:%d/gpu:%d" % (FLAGS.task_index, gpu_num))):

And I used the tf.train.SyncReplicasOptimizer to implement the SyncTraining.

This is part of my seq2seq_model.py:

# Gradients and SGD update operation for training the model.
params = tf.trainable_variables()
if not forward_only:
  self.gradient_norms = []
  self.updates = []
  opt = tf.train.GradientDescentOptimizer(self.learning_rate)
  opt = tf.train.SyncReplicasOptimizer(
    opt,
    replicas_to_aggregate=num_workers,
    replica_id=task_index,
    total_num_replicas=num_workers)      

  for b in xrange(len(buckets)):
    gradients = tf.gradients(self.losses[b], params)
    clipped_gradients, norm = tf.clip_by_global_norm(gradients,
                                                     max_gradient_norm)
    self.gradient_norms.append(norm)
    self.updates.append(opt.apply_gradients(
          zip(clipped_gradients, params), global_step=self.global_step))


self.init_tokens_op = opt.get_init_tokens_op
self.chief_queue_runners = [opt.get_chief_queue_runner]
self.saver = tf.train.Saver(tf.all_variables())

This is my complete python code [here]

Upvotes: 1

Views: 369

Answers (1)

y.selivonchyk
y.selivonchyk

Reputation: 9900

It seems like Tensorflow people are not ready yet to properly share the experience of running code on a cluster. So far comprehensive documentation can be found only in the source code.

As of version 0.11 according to SyncReplicasOptimizer.py you have to run this after SyncReplicasOptimizer construction:

init_token_op = optimizer.get_init_tokens_op()
chief_queue_runner = optimizer.get_chief_queue_runner()

And then run this after your session is constructed with Supervisor:

  if is_chief:
    sess.run(init_token_op)
    sv.start_queue_runners(sess, [chief_queue_runner])

With SyncReplicasOptimizerV2 introduced with 0.12 this code might not be sufficient so, please, refer to the source code of the version you use.

Upvotes: 1

Related Questions