Skip to content

Instantly share code, notes, and snippets.

@AIAnytime
Created February 19, 2021 06:06
Show Gist options
  • Save AIAnytime/2337e550d172141d78cd1f1aa062a0e5 to your computer and use it in GitHub Desktop.
Save AIAnytime/2337e550d172141d78cd1f1aa062a0e5 to your computer and use it in GitHub Desktop.
Few snippets to work with GPU memory management while working with Keras
#1st snippet
from keras import backend as K
cfg = K.tf.ConfigProto()
cfg.gpu_options.allow_growth = True
K.set_session(K.tf.Session(config=cfg))
#2nd snippet
def limit_mem():
K.get_session().close()
cfg = K.tf.ConfigProto()
cfg.gpu_options.allow_growth = True
K.set_session(K.tf.Session(config=cfg))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment