CamDavidsonPilon / Probabilistic-Programming-and-Bayesian-Methods-for-Hackers

aka "Bayesian Methods for Hackers": An introduction to Bayesian methods + probabilistic programming with a computation/understanding-first, mathematics-second point of view. All in pure Python ;)
http://camdavidsonpilon.github.io/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/
MIT License
26.51k stars 7.84k forks source link

Chapter 2 | UDF reset_sess | TFP #432

Closed Pindar777 closed 5 years ago

Pindar777 commented 5 years ago

Hi there,

in TFP variants there is a UDF called reset_sess() and it is used to initiate the anlysis and later when tackling different models 'to start over' again. However, it struck me that when running the function there is the following warning

AppData\Roaming\Python\Python36\site-packages\tensorflow\python\client\session.py:1702: UserWarning: An interactive session is already active. This can cause out-of-memory errors in some cases. You must explicitly callInteractiveSession.close()to release resources held by the other session(s). warnings.warn('...'

This happens also when running sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))

In terms of the last line it does lead to endless execution in my system when running in graph-mode. Eventually I figured out that it's necessary to always run this line `sess = tf.Session(config=tf.ConfigProto(log_device_placement=False)) before initializing any created variables.

Where is the bug and how to repair it?

Pindar777 commented 5 years ago

Do not mix up an InteractiveSession with a normal Session ;-)