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