Created
October 11, 2018 17:21
-
-
Save amarion35/8c4452f0f70b1e7eebe1119c68843c87 to your computer and use it in GitHub Desktop.
Choose your GPU and limit Keras memory usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| os.environ["CUDA_VISIBLE_DEVICES"]="1" #Before all | |
| import tensorflow as tf | |
| config = tf.ConfigProto() | |
| config.gpu_options.allow_growth = True # Use only necessary memory | |
| #config.gpu_options.per_process_gpu_memory_fraction = 0.5 | |
| session = tf.Session(config=config) # Before importing Keras! | |
| from keras.backend.tensorflow_backend import set_session | |
| set_session(session) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment