问题描述:
Exception ignored in: <bound method BaseSession.del of <tensorflow.python.client.session.Session object at 0x7fb4ecd301d0>>
Traceback (most recent call last):
File "/home/magnus/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 171, in del
File "/home/magnus/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 167, in close
AttributeError: 'NoneType' object has no attribute 'raise_exception_on_not_ok_status'
Process finished with exit code 0
解决方案:
it induced by different gc sequence, if python collect session first , the program will exit successfully, if python collect swig memory(tf_session) first, the program exit with failure.
you can force python to del session by:
del session
or if you are using keras, you cant get the session instance, you can run following code at end of your code:
import gc; gc.collect()
with tf.Session() as session:
session.run(...)
del session
网友评论