tensorflow: tensorflow2rc1 import bug
Hi, I was trying to convert one of my training templates to TensorFlow2 but encountered several issues. I can not reach a point where my code is even executed because many imports already terminate the application at start.
from tensorflow_core.python.client.session import InteractiveSession
def main():
print('hello world')
if __name__ == "__main__":
main()
This code results instantly in an error and the print is never reached.
2019-09-17 09:18:51.362815: E tensorflow/core/lib/monitoring/collection_registry.cc:77] Cannot register 2 metrics with the same name: /tensorflow/api/python/session_create_counter
Traceback (most recent call last):
File "/home/xxx/dev/tf2xxx/bug.py", line 1, in <module>
from tensorflow_core.python.client.session import InteractiveSession
File "/home/xxx/.virtualenv/tf2/lib/python3.6/site-packages/tensorflow_core/python/client/session.py", line 49, in <module>
'Counter for number of sessions created in Python.')
File "/home/xxx/.virtualenv/tf2/lib/python3.6/site-packages/tensorflow_core/python/eager/monitoring.py", line 183, in __init__
name, description, *labels)
File "/home/xxx/.virtualenv/tf2/lib/python3.6/site-packages/tensorflow_core/python/eager/monitoring.py", line 121, in __init__
self._metric = self._metric_methods[self._label_length].create(*args)
tensorflow.python.framework.errors_impl.AlreadyExistsError: Another metric with the same name already exists.
Next to InteractiveSession there are multiple other imports that cause problems with monitoring.py. Changing to tf2’s eager mode and not worry about the session did not do the trick.
Keras however runs fine and does not cause any problems (except the conv2d layer + CUDA what causes problems for a while already).
System information
- OS Platform and Distribution: Ubuntu 18.04
- TensorFlow installed from: pip3
- TensorFlow version: 2.0.0rc1
- Python version: 3.6.8
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (3 by maintainers)
Don’t import directly from
tensorflow_core, that is private API and will change under you and break you.This import is what’s causing your problem