title: TensorFlow supervisor prevents variable assignment: Graph is finalized and cannot be modified
body: <p>This code works fine:</p>
  
  <pre><code>import tensorflow as tf
  x = tf.Variable(initial_value=0)
  
  with tf.Session() as session:
      print session.run(x.assign(1))
  </code></pre>
  
  <p>But this code fails:</p>
  
  <pre><code>import tensorflow as tf
  x = tf.Variable(initial_value=0)
  supervisor = tf.train.Supervisor(logdir="/tmp")
  
  with tf.Session() as session:
      print session.run(x.assign(1))
  </code></pre>
  
  <p>The only difference is the instantiation of a <code>tf.train.Supervisor</code>. Note that we don't even use the supervisor to create a managed session.</p>
  
  <p>The error is:</p>
  
  <pre><code>python tf_supervisor_freeze.py
  Traceback (most recent call last):
    File "tf_supervisor_freeze.py", line 6, in &lt;module&gt;
      print session.run(x.assign(1))
    File "&lt;virtual_env_path&gt;/lib/python2.7/site-packages/tensorflow/python/ops/variables.py", line 522, in assign
      return state_ops.assign(self._variable, value, use_locking=use_locking)
    File "&lt;virtual_env_path&gt;/lib/python2.7/site-packages/tensorflow/python/ops/gen_state_ops.py", line 47, in assign
      use_locking=use_locking, name=name)
    File "&lt;virtual_env_path&gt;/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 491, in apply_op
      preferred_dtype=default_dtype)
    File "&lt;virtual_env_path&gt;/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 702, in internal_convert_to_tensor
      ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
    File "&lt;virtual_env_path&gt;/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 110, in _constant_tensor_conversion_function
      return constant(v, dtype=dtype, name=name)
    File "&lt;virtual_env_path&gt;/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 103, in constant
      attrs={"value": tensor_value, "dtype": dtype_value}, name=name).outputs[0]
    File "&lt;virtual_env_path&gt;/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2286, in create_op
      self._check_not_finalized()
    File "&lt;virtual_env_path&gt;/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2009, in _check_not_finalized
      raise RuntimeError("Graph is finalized and cannot be modified.")
  RuntimeError: Graph is finalized and cannot be modified.
  
  Process finished with exit code 1
  </code></pre>
  
  <p>Error remains if <code>tf.train.Supervisor(logdir="/tmp", summary_op=None, saver=None)</code> is used to disable some of the supervisor's services.</p>
  
  <p>This problem was raised by somebody else on <a href="https://github.com/tensorflow/tensorflow/issues/8235" rel="nofollow noreferrer">Github</a> but no answer was provided there; the request was to raise the issue on StackOverflow instead. The only relevant <a href="https://stackoverflow.com/questions/41798311/tensorflow-graph-is-finalized-and-cannot-be-modified">StackOverflow question</a> does not appear to address this specific case.</p>