tensorflow and tensorflow2.0 control memory

tensorflow and tensorflow2.0 control memory

The following methods may be implemented to control tensorflow keras memory or adaptive.

if tf.__version__.startswith('1.'):  # tensorflow 1
    config = tf.ConfigProto()  # allow_soft_placement=True
    config.gpu_options.allow_growth = True
    sess = tf.Session(config=config)
else:  # tensorflow 2
    tf.config.gpu.set_per_process_memory_growth(enabled=True)

The first method for controlling an adaptive memory tensorflow 1.x versions, to avoid memory exclusive. A second method for controlling the use of adaptive tensorflow 2.x memory.

Original Address: https://doit-space.blog.csdn.net/article/details/102911328

Published 143 original articles · won praise 345 · views 470 000 +

Guess you like

Origin blog.csdn.net/qq_31456593/article/details/102911328