tensorflow: [TF 2.0] tf.estimator.ProfilerHook... is not compatible with eager execution
System information
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Debian 8.8
- Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
- TensorFlow installed from (source or binary): via pip
- TensorFlow version (use command below):
tf.__git_version__ : 'v1.12.0-9492-g2c319fb415', version tensorflow==2.0.0-alpha0 - Python version: 3.6
- Bazel version (if compiling from source): NA
- GCC/Compiler version (if compiling from source): NA
- CUDA/cuDNN version: NA
- GPU model and memory: NA
Describe the current behavior
When constructing a tf.estimator.ProfilerHook a error is thrown: RuntimeError: tf.summary.FileWriter is not compatible with eager execution. Use tf.contrib.summary instead.
Describe the expected behavior
Code to reproduce the issue
import tensorflow as tf
tf.estimator.ProfilerHook(10)
Other info / logs
Iām not very familiar with tf 2.0, so maybe this is just user error? Is it possible to use tf2 not in eager mode?
Full traceback:
RuntimeError Traceback (most recent call last)
<ipython-input-7-4eefc50dcc45> in <module>
----> 1 tf.estimator.ProfilerHook(10)
~/tf2-venv/lib/python3.6/site-packages/tensorflow/python/training/basic_session_run_hooks.py in __init__(self, save_steps,save_secs, output_dir, show_dataflow, show_memory)
1013 """
1014 self._output_file = os.path.join(output_dir, "timeline-{}.json")
-> 1015 self._file_writer = SummaryWriterCache.get(output_dir)
1016 self._show_dataflow = show_dataflow
1017 self._show_memory = show_memory
~/tf2-venv/lib/python3.6/site-packages/tensorflow/python/summary/writer/writer_cache.py in get(logdir)
61 if logdir not in FileWriterCache._cache:
62 FileWriterCache._cache[logdir] = FileWriter(
---> 63 logdir, graph=ops.get_default_graph())
64 return FileWriterCache._cache[logdir]
~/tf2-venv/lib/python3.6/site-packages/tensorflow/python/summary/writer/writer.py in __init__(self, logdir, graph, max_queue, flush_secs, graph_def, filename_suffix, session)
358 if context.executing_eagerly():
359 raise RuntimeError(
--> 360 "tf.summary.FileWriter is not compatible with eager execution. "
361 "Use tf.contrib.summary instead.")
362 if session is not None:
RuntimeError: tf.summary.FileWriter is not compatible with eager execution. Use tf.contrib.summary instead.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 22 (11 by maintainers)
The bug still exists in tensorflow==2.0.0-beta1
System information
Code to reproduce the issue
Other Info / Logs
The full traceback is listed as follows:
The instruction from compat.v1 still works fine, which makes the code a little bit ugly.
Thank for your attention.
I think we should make it work in TF2. Will take a look what the options are here.
@lendle Could you try this to disable eager execution in 2.0 import tensorflow as tf tf.compat.v1.disable_eager_execution() tf.estimator.ProfilerHook(10)
Thanks!