nimish1512 / Emotion-recognition-and-prediction

A streamlined system to detect human emotions from image and voice and predict its reaction

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gpu memory usage

ArashHosseini opened this issue · comments

@nimish1512 know a solution to minimize the GPU memory usage?
thank you

Assuming you have 12GB of GPU memory and want to allocate 6GB:
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.5)
with tf.Session(config=tf.ConfigProto(gpu_options=gpu_options)) as sess:

This will force tensorflow to use only 50% of your GPU memory. Similarly, you can change the fraction value as per need

@nimish1512 thx,
this will not fix it sadly, i changed in trainer/restore(from 448) already the following lines

            config = tf.ConfigProto()
            tflearn_conf = tf.get_collection(tf.GraphKeys.GRAPH_CONFIG)
            if tflearn_conf:
                config = tflearn_conf[0]
            #config.gpu_options.allow_growth=True
            config.gpu_options.per_process_gpu_memory_fraction = 0.5
            self.session = tf.Session(config=config)

and still using 9GB, i solved it with changes on trainer/init(from 114)

            if not session:
                config = tf.ConfigProto()
                config.gpu_options.allow_growth=True
                self.session = tf.Session(config=config)