解决办法 用tensorflow的时候都用下面三行: config = tf.ConfigProto() config.gpu_options.allow_growth = True with tf.Session(config=config) as sess: