from __future__ import absolute_import, division, print_function
import os
import matplotlib.pyplot as plt
import tensorflow as tf
print(tf.VERSION) # => 1.7.0
import tensorflow.contrib.eager as tfe
tf.enable_eager_execution()
ValueError Traceback (most recent call last)
<ipython-input-59-0c62cac7517d> in <module>()
7 import tensorflow.contrib.eager as tfe
8
----> 9 tf.enable_eager_execution()
D:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py in enable_eager_execution(config, device_policy)
5242 if graph_mode_has_been_used:
5243 raise ValueError(
-> 5244 "tf.enable_eager_execution must be called at program startup.")
5245 context._default_mode = context.EAGER_MODE
5246 if context._context is None:
ValueError: tf.enable_eager_execution must be called at program startup.
Sounds like the Jupyter kernel needs to be restarted.
@asimshankar Thanks guy, but restarting the runtime does not work for me, even I change the notebook environment to python2 without GPU.
For now, you can restart the colab runtime (“Runtime -> Restart Runtime…”). In future releases, I think the error will go away (thanks to e2c6ec9e86dd86e0dd56e0f11302a5bf5d9ed440)
tf.enable_eager_execution()
is intended to be called once in a program, typically the first thing in a program. Libraries should not be callingtf.enable_eager_execution()
and instead should in general work for both graph construction and eager execution (orassert tf.executing_eagerly()
if they work only with eager execution).That said, I can’t reproduce the error you’re seeing using the snippet provided. Is there more to reproducing the problem? Thanks.