Session.close() doesn't free resources on GPU using tensorflow.

落花浮王杯 提交于 2020-01-06 02:00:25

问题


I would like to perform pretraining of neural network using autoencoders implemented in TensorFlow.

  1. I am able to run whole network. (Using TF or Keras). the whole graph fits into GPU memory so that's fine.
  2. Problem occurs when I create more graphs (autoencoders). GPU run out of memory very quickly. Right now I have example where building second level autoencoder causes GPU out of mem. exception.

So what is happening:

I have implementation of autoencoders which has session as it's attribute, so :

self.session = tf.Session() 

and implements method

destroy()

where

self.session.close()

is called.

When stacking autoencoders, some instances of Session are needed and that's when I got the problem.

What am I missing? isn't .close() enough?

Thanks

来源:https://stackoverflow.com/questions/37470667/session-close-doesnt-free-resources-on-gpu-using-tensorflow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!