title: tensorflow restore model and do inference failed with Dataset iterator initialization failure error
body: <p>I restored trained model as below</p>
  
  <pre><code>saver = tf.train.import_meta_graph('expr1.multi/train_logs/model.ckpt-44.meta')
  sess = tf.Session(config=tf.ConfigProto(allow_soft_placement=True))
  saver.restore(sess,'expr1.multi/train_logs/model.ckpt-44')
  </code></pre>
  
  <p>and then retrieve the tensors needed for inference as</p>
  
  <pre><code>logits = graph.get_tensor_by_name('strided_slice_1:0')
  logits_len = graph.get_tensor_by_name('strided_slice_2:0')
  targets = graph.get_tensor_by_name('evaluate/IteratorGetNext:2')
  targets_len = graph.get_tensor_by_name('evaluate/IteratorGetNext:3')
  
  # this is to retrieve the dataset.iterator.initializer operator
  init_op = graph.get_operation_by_name('evaluate/MakeIterator')
  </code></pre>
  
  <p>then do the inference</p>
  
  <pre><code>sess.run(init_op)
  while True:
      try:
          l, ll, t, tl = sess.run([logits, logits_len, targets, targets_len])
          ...
      except tf.errors.OutOfRangeError:
  </code></pre>
  
  <p>and in case for model trained with single gpu training above model restoring and inference works fine without issue. However with below multiple gpu training (asynchronous) implementation, it failed</p>
  
  <pre><code>    loss_ops = []
      train_ops = []
      for gpu_i in range(self.num_gpus):
          with tf.device("/gpu:%d" % gpu_i):
              loss = ...
              # update the model parameter
              update = self.model.update(loss, global_step, self.lrate, self.grad_clip)
              loss_ops.append(loss)
              train_ops.append(update)
  
      # within this Dataset pipe is created for evaluation data
      evaluator = get_evaluator(self.evaluator)(self.conf, self.model)
  
      mon_sess = tf.train.MonitoredTrainingSession(config=config, hooks=hooks)
      ...
  
      def train_helper(train_op, loss_op):
          ...
          while not mon_sess.should_stop() and has_data:
              try:
                  _, lossVal, step = mon_sess.run([train_op, loss_op, global_step])
              except tf.errors.OutOfRangeError:
                  has_data = False
                  continue
  
              #validation loss evaluation every eval_steps steps
              if not step == 0 and step % self.eval_steps == 0:
  
                  # one shot iterator initialization done inside evaluate function
                  val_lossVal, num_utts = evaluator.evaluate(mon_sess)
                  ...
  
      train_threads = []
      for t_op, loss_op in zip(train_ops, loss_ops):
          train_threads.append(threading.Thread(target=train_helper, args=(t_op, loss_op)))
  
      # Start the threads, and block on their completion.
      for t in train_threads:
          t.start()
      for t in train_threads:
          t.join()
  </code></pre>
  
  <p>below dataset pipe iterator initialization failing error</p>
  
  <p>tensorflow.python.framework.errors_impl.FailedPreconditionError: GetNext() failed because the iterator has not been initialized. Ensure that you have run the initializer operation for this iterator before getting the next element.</p>
  
  <p>I could not figure out the reason.</p>