harvitronix / five-video-classification-methods

Code that accompanies my blog post outlining five video classification methods in Keras and TensorFlow
https://medium.com/@harvitronix/five-video-classification-methods-implemented-in-keras-and-tensorflow-99cad29cc0b5
MIT License
1.18k stars 478 forks source link

How to allowing GPU memory growth #38

Closed AnsusBega closed 6 years ago

AnsusBega commented 6 years ago

Hi,

I'd like to limit the memory of each GPU. I found the following code and I paste it in train.py, but it doesn't work. What am I doing wrong? Thanks in advance.

if name == 'main': config = tf.ConfigProto() config.gpu_options.allow_growth = False config.gpu_options.per_process_gpu_memory_fraction = 0.5 set_session(tf.Session(config=config)) main()

AnsusBega commented 6 years ago

I solved the problem setting the session before importing keras in train.py:

""" Train our RNN on extracted features or images. """ import tensorflow as tf config = tf.ConfigProto() config.gpu_options.allow_growth = True session = tf.Session(config=config) from keras.callbacks import TensorBoard, ModelCheckpoint, EarlyStopping, CSVLogger

harvitronix commented 6 years ago

Thanks for sharing!