Skip to content

Instantly share code, notes, and snippets.

@Puzer
Last active February 12, 2020 12:59
Show Gist options
  • Save Puzer/c262e3c51fcbdf2e398bdaa2ba420c14 to your computer and use it in GitHub Desktop.
Save Puzer/c262e3c51fcbdf2e398bdaa2ba420c14 to your computer and use it in GitHub Desktop.
Limit GPU memory
# https://www.tensorflow.org/programmers_guide/using_gpu#allowing_gpu_memory_growth
import tensorflow as tf
from keras.backend.tensorflow_backend import set_session
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
config.gpu_options.per_process_gpu_memory_fraction = 0.5
sess = tf.Session(config=config)
set_session(sess)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment