tensorflow-handbook
tensorflow-handbook copied to clipboard
设置显存使用策略
设置显存按需使用的 code 报错。
gpus = tf.config.experimental.list_physical_devices(device_type='GPU')
for gpu in gpus:
tf.config.experimental.set_memory_growth(device=gpu, True)
显示 SyntaxError: positional arguments follows keyword argument
第三行需要修改一下才能运行
tf.config.experimental.set_memory_growth(gpu, True)
或
tf.config.experimental.set_memory_growth(device=gpu, enable=True)