Limit_mem Error

Running limit_mem() is giving error as,

RuntimeError Traceback (most recent call last)
in ()
1 # Tell Tensorflow to use no more GPU RAM than necessary
----> 2 limit_mem()

~/nbs/utils2.py in limit_mem()
40
41 def limit_mem():
—> 42 K.get_session().close()
43 cfg = K.tf.ConfigProto()
44 cfg.gpu_options.allow_growth = True

~/anaconda3/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py in get_session()
173 # not already marked as initialized.
174 is_initialized = session.run(
–> 175 [tf.is_variable_initialized(v) for v in candidate_vars])
176 uninitialized_vars = []
177 for flag, v in zip(is_initialized, candidate_vars):

~/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata)
765 try:
766 result = self._run(None, fetches, feed_dict, options_ptr,
–> 767 run_metadata_ptr)
768 if run_metadata:
769 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

~/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
903 raise RuntimeError(‘Attempted to use a closed Session.’)
904 if self.graph.version == 0:
–> 905 raise RuntimeError('The Session graph is empty. Add operations to the '
906 ‘graph before calling run().’)
907

RuntimeError: The Session graph is empty. Add operations to the graph before calling run().

Please help!

Thanks,
Naman

I’ve just run into the same issue. Did you have a solution? Thanks in advance.

Hi,

See step #16 from this post to see how I dealt with the issue.

Thanks,
Patrick

Thank you!! :slight_smile: