我正在使用拥抱脸给出的glue example for tf。 为了限制GPU的增长,我添加了功能:
def limit_gpu(gpu_number):
gpus = tf.config.experimental.list_physical_devices('GPU')
if gpus:
# Restrict TensorFlow to only use the first GPU
try:
tf.config.experimental.set_visible_devices(gpus[gpu_number], 'GPU')
tf.config.experimental.set_memory_growth(gpus[gpu_number], True)
logical_gpus = tf.config.experimental.list_logical_devices('GPU')
print(len(gpus), "Physical GPUs,", len(logical_gpus), "Logical GPU")
except RuntimeError as e:
# Visible devices must be set before GPUs have been initialized
print(e)
但是,在我调用limit_gpu()之后的调试过程中,我发现nividia-smi指出GPU的使用为707MB。
那怎么可能?这些707MB是什么?在这种“空闲”状态下,我可以降低GPU使用率吗?