import tensorflow as tf tf_config = tf.ConfigProto(allow_soft_placement=True) tf_config.gpu_options.allow_growth = True global_step = tf.train.get_or_create_global_step(