Limit tensorflow usage to 1GB VRAM

This commit is contained in:
henryruhs 2023-06-22 21:07:25 +02:00
parent b7cf5df2f3
commit d46fd55b91

View File

@ -129,7 +129,9 @@ def limit_resources() -> None:
# prevent tensorflow memory leak
gpus = tensorflow.config.experimental.list_physical_devices('GPU')
for gpu in gpus:
tensorflow.config.experimental.set_memory_growth(gpu, True)
tensorflow.config.experimental.set_virtual_device_configuration(gpu, [
tensorflow.config.experimental.VirtualDeviceConfiguration(memory_limit=1024)
])
# limit memory usage
if roop.globals.max_memory:
memory = roop.globals.max_memory * 1024 ** 3