From 5f0f97634f780516147ca26ddb826b1df6bb0ef6 Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Tue, 28 Feb 2023 13:39:30 -0500 Subject: [PATCH] Only clear cuda cache on CUDA since it causes slowdowns on ROCm. --- execution.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/execution.py b/execution.py index 69761eb0..128c5638 100644 --- a/execution.py +++ b/execution.py @@ -189,8 +189,10 @@ class PromptExecutor: self.server.send_sync("executing", { "node": None }, self.server.client_id) gc.collect() - torch.cuda.empty_cache() - torch.cuda.ipc_collect() + if torch.cuda.is_available(): + if torch.version.cuda: #This seems to make things worse on ROCm so I only do it for cuda + torch.cuda.empty_cache() + torch.cuda.ipc_collect() def validate_inputs(prompt, item):