Error: the tensor's graph is different from the session's graph
<p>I am trying to load a previously trained tensor trained model from checkpoint files, now these checkpoint files has op varaibles in them so to load the graph I have to first load graph_def from **ckpt.meta file:</p>
<pre><code>graph = tf.Graph()
sess = tf.InteractiveSession(graph=graph)
saver = tf.train.import_meta_graph('/data/model_cache/model.ckpt-39.meta')
    ckpt = tf.train.get_checkpoint_state(FLAGS.checkpoint_dir)
    if ckpt and ckpt.model_checkpoint_path:
       if os.path.isabs(ckpt.model_checkpoint_path):
          saver.restore(sess, ckpt.model_checkpoint_path)
</code></pre>
<p>After I have loaded the models I have a method that uses this model for inference to implement <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/tutorials/deepdream/deepdream.ipynb" rel="nofollow noreferrer">deep-dream</a> algo . The problem is when I call eval with the default session I get below error:</p>
<pre><code>File &quot;/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py&quot;, line 555, in eval
return _eval_using_default_session(self, feed_dict, self.graph, session)File &quot;/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework   /ops.py&quot;, line 3495, in _eval_using_default_session
raise ValueError(&quot;Cannot use the given session to evaluate tensor: &quot;
ValueError: Cannot use the given session to evaluate tensor: the tensor's graph is different from the session's graph.
</code></pre>
<hr />
<p>I have confirmed that <code>tf.get_default_graph()</code> and <code>sess.graph</code> are pointing to same memory address. There has to be something very basic I am missing.</p>