From c78e8f1e3a5a7cee648987e3a58199f524bdb090 Mon Sep 17 00:00:00 2001 From: isalia20 Date: Fri, 19 Apr 2024 23:36:23 +0400 Subject: [PATCH 1/3] add cuda empty cache to properly release cuda memory --- backgroundremover/u2net/detect.py | 1 + 1 file changed, 1 insertion(+) diff --git a/backgroundremover/u2net/detect.py b/backgroundremover/u2net/detect.py index cda5184..d0246b2 100644 --- a/backgroundremover/u2net/detect.py +++ b/backgroundremover/u2net/detect.py @@ -151,5 +151,6 @@ def predict(net, item): img = Image.fromarray(predict_np * 255).convert("RGB") del d1, d2, d3, d4, d5, d6, d7, pred, predict, predict_np, inputs_test, sample + torch.cuda.empty_cache() if torch.cuda.is_available() else None return img From 4ba6485277eb87a12cd1915dba13712c056d806b Mon Sep 17 00:00:00 2001 From: isalia20 Date: Fri, 19 Apr 2024 23:36:37 +0400 Subject: [PATCH 2/3] Revert "add cuda empty cache to properly release cuda memory" This reverts commit c78e8f1e3a5a7cee648987e3a58199f524bdb090. --- backgroundremover/u2net/detect.py | 1 - 1 file changed, 1 deletion(-) diff --git a/backgroundremover/u2net/detect.py b/backgroundremover/u2net/detect.py index d0246b2..cda5184 100644 --- a/backgroundremover/u2net/detect.py +++ b/backgroundremover/u2net/detect.py @@ -151,6 +151,5 @@ def predict(net, item): img = Image.fromarray(predict_np * 255).convert("RGB") del d1, d2, d3, d4, d5, d6, d7, pred, predict, predict_np, inputs_test, sample - torch.cuda.empty_cache() if torch.cuda.is_available() else None return img From dfa4dd8e9a46e1b45f3d77187bd7126d081bf5ce Mon Sep 17 00:00:00 2001 From: isalia20 Date: Fri, 19 Apr 2024 23:37:20 +0400 Subject: [PATCH 3/3] add cuda empty cache to properly release cuda memory --- backgroundremover/u2net/detect.py | 1 + 1 file changed, 1 insertion(+) diff --git a/backgroundremover/u2net/detect.py b/backgroundremover/u2net/detect.py index cda5184..d0246b2 100644 --- a/backgroundremover/u2net/detect.py +++ b/backgroundremover/u2net/detect.py @@ -151,5 +151,6 @@ def predict(net, item): img = Image.fromarray(predict_np * 255).convert("RGB") del d1, d2, d3, d4, d5, d6, d7, pred, predict, predict_np, inputs_test, sample + torch.cuda.empty_cache() if torch.cuda.is_available() else None return img