tensorflow: Unexpected warning during GeneratorDataset iterator finalization
System information
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow):
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 14.04
- Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: N/A
- TensorFlow installed from (source or binary): binary
- TensorFlow version (use command below):
('v1.12.0-0-ga6d8ffae09', '1.12.0')
- Python version: 2.7
- Bazel version (if compiling from source): N/A
- GCC/Compiler version (if compiling from source): N/A
- CUDA/cuDNN version: N/A
- GPU model and memory:
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 410.73 Driver Version: 410.73 CUDA Version: 10.0 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 Quadro M2000M Off | 00000000:01:00.0 On | N/A |
| N/A 57C P0 N/A / N/A | 832MiB / 4043MiB | 4% Default |
+-------------------------------+----------------------+----------------------+
Describe the current behavior
When using from_generator
to create a tf.data.Dataset
instance, reading from a one_shot_iterator and not explicitly closing the session object, I observe a warning:
W tensorflow/core/kernels/data/generator_dataset_op.cc:78] Error occurred when finalizing GeneratorDataset iterator: Failed precondition: Python interpreter state is not initialized. The process may be terminated.
Describe the expected behavior Would expect the program to finish without a warning.
Code to reproduce the issue
import itertools
import tensorflow as tf
def gen():
for i in itertools.count(1):
yield (i, [1] * i)
ds = tf.data.Dataset.from_generator(
gen, (tf.int64, tf.int64), (tf.TensorShape([]), tf.TensorShape([None])))
iterator = ds.make_one_shot_iterator()
sess = tf.Session()
iterator = iterator.get_next()
sess.run(iterator)
# sess.close() <-- no warning is shown if closing the session explicitly
Other info / logs
2018-12-25 23:43:21.645869: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2018-12-25 23:43:21.684610: W tensorflow/core/kernels/data/generator_dataset_op.cc:78] Error occurred when finalizing GeneratorDataset iterator: Failed precondition: Python interpreter state is not initialized. The process may be terminated.
[[{{node PyFunc}} = PyFunc[Tin=[DT_INT64], Tout=[DT_INT64], token="pyfunc_2"](arg0)]]
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 24 (15 by maintainers)
@jvishnuvardhan we have this issue in 2.0b1
I’m having the same issue using TF 2.2.0 and Python 3.8.4. I’m trying to run a simplified convnet with the following code:
Running the above code yields the following error message:
I’ve played around with this code some more and noticed that removing the input_shape argument from the first conv layer eliminates the “Failed precondition” error, allowing the program to run normally; likewise, putting another layer (e.g. MaxPooling2D) first and including input_shape causes the error to occur. Furthermore, if I run a single image through the network (which involves removing the ImageDataGenerator().flow_from_directory()), the program runs normally even with the input_shape argument in the first layer.
@bionicles Could you open a new issue by filling issue template and also provide a standalone code to reproduce the issue? As the origianal issue with TF1.x was resolved, it is better to open a new issue so that it will help the community that are using TF2.0. Thanks!
I have the same issue as well