tensorflow: AttributeError: 'NoneType' object has no attribute 'TF_NewStatus

In the latest sources the issue: https://github.com/tensorflow/tensorflow/issues/3388 is fixed in the thensorflow/python/client/session.py, But I now receive the following error instead:

Exception ignored in: <bound method BaseSession.__del__ of <tensorflow.python.client.session.Session object at 0x7fb2e08cee48>>
Traceback (most recent call last):
  File "$HOME/.local/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 595, in __del__
AttributeError: 'NoneType' object has no attribute 'TF_NewStatus'

I compiled the model manually using the latest version sources and using Bazel 0.4.5. The same seems to be true as with the issue 3388: The error is not always popping up and the run seems to have ended normally. However, now and then to above error message is displayed.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 2
  • Comments: 32 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Hi, I also have this issue. It pops up from time to time. Keras 2.0.3 and tensorflow 1.1.0.

I get the same error.

from keras import backend as K
K.clear_session()

Using this line at the end of the code seems to fix it It feels like a work around though.

I had the same problem and checking the code in the file /lib/python3.5/site-packages/tensorflow/python/client/session.py shows this:

try:
        status = tf_session.TF_NewStatus()
        tf_session.TF_DeleteDeprecatedSession(self._session, status)

the error could be avoided with something like this:

try:
        if tf_session is not None:
            status = tf_session.TF_NewStatus()
            tf_session.TF_DeleteDeprecatedSession(self._session, status)

Solution of Nimi42 worked for me as well to solve this issue. I added:

from keras import backend as K K.clear_session()

Using python 3.5.2, tf 1.9, and tensorflow.contrib.keras

Seeing this issue intermittently as well. It is fairly annoying as it sometimes splits my output in half.

I’m using tensorflow 1.5.0 via docker (gcr.io/tensorflow/tensorflow:1.5.0-devel-gpu-py3) and keras 2.1.3. The following exception sometimes occurs:

Exception ignored in: <bound method BaseSession.__del__ of <tensorflow.python.client.session.Session object at 0x7fa52147f898>>
Traceback (most recent call last): 
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 702, in __del__
TypeError: 'NoneType' object is not callable

I’m not sure if it’s related, but other times my script does not exit and keeps hanging. This makes automatic parameter tuning a hassle.

I’m not sure if this is the same error or not; it’s saying not callable rather than the attribute, but seems to be in the same method anyway…

Exception ignored in: <bound method BaseSession.__del__ of <tensorflow.python.client.session.Session object at 0x7f4cfbc42e10>>
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 696, in __del__
TypeError: 'NoneType' object is not callable

using tensorflow 1.4.1 in docker, using tensorflow/tensorflow:latest-gpu-py3 not using keras, but I am using sess = tf.Session() and sess.close() instead of with tf.Session() as sess: but that doesn’t seem to be sufficient to recreate the error reliably in say ipython3, it only happens when I run my script. perhaps some sort of race condition?

Dear skye,

thank you for your response. Triggered by your question, I found out that this issue is only occurring when using the Keras module. When I use the Tensorflow module directly I’m not able to reproduce the issue. I assumed that the tensorflow was the issue, as issue #3388 was also occurring at the same moment when I ran my Keras test scripts. Next to that, the error message also reported the issue was occurring in the session.py python script that is part of tensorflow. I will report the issue at the Keras project. Sorry for the inconvenience…