tf.config.experimental.set_memory_growth
| View source on GitHub |
Установить, должно ли быть включено увеличение памяти для PhysicalDevice.
tf.config.experimental.set_memory_growth(
device, enable
)
Если увеличение памяти включено для PhysicalDevice, при инициализации выполнения не будет выделена вся память на устройстве. Увеличение памяти нельзя настроить на PhysicalDevice с настроенными виртуальными устройствами.
Например:
physical_devices = tf.config.list_physical_devices('GPU')
try:
tf.config.experimental.set_memory_growth(physical_devices[0], True)
except:
# Invalid device or cannot modify virtual devices once initialized.
pass
| Аргументы | |
|---|---|
device | PhysicalDevice для настройки |
enable | (Булево) Включить или отключить увеличение памяти |
| Исключения | |
|---|---|
ValueError | Указано неверное PhysicalDevice. |
RuntimeError | Выполнение уже инициировано. |
© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.3/api_docs/python/tf/config/experimental/set_memory_growth