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.4/api_docs/python/tf/config/experimental/set_memory_growth