From c7836861a269c285747f08cee64eb678541f62b7 Mon Sep 17 00:00:00 2001 From: RandomGitUser321 Date: Wed, 26 Jun 2024 18:44:28 -0400 Subject: [PATCH 1/4] torch.cuda.empty_cache() --- web_demo.py | 1 + 1 file changed, 1 insertion(+) diff --git a/web_demo.py b/web_demo.py index 668dcf4d..eae8c54e 100644 --- a/web_demo.py +++ b/web_demo.py @@ -158,6 +158,7 @@ def chat(img, msgs, ctx, params=None, vision_hidden_states=None): res = res.replace('', '') res = res.replace('', '') answer = res.replace('', '') + torch.cuda.empty_cache() return 0, answer, None, None except Exception as err: print(err) From 79a95a8c0a3f87d8febbd92081d97bc0541680fe Mon Sep 17 00:00:00 2001 From: RandomGitUser321 Date: Wed, 26 Jun 2024 18:44:48 -0400 Subject: [PATCH 2/4] torch.cuda.empty_cache() --- web_demo_2.5.py | 1 + 1 file changed, 1 insertion(+) diff --git a/web_demo_2.5.py b/web_demo_2.5.py index 6f6b81af..94780c7a 100644 --- a/web_demo_2.5.py +++ b/web_demo_2.5.py @@ -150,6 +150,7 @@ def chat(img, msgs, ctx, params=None, vision_hidden_states=None): res = res.replace('', '') res = res.replace('', '') answer = res.replace('', '') + torch.cuda.empty_cache() return 0, answer, None, None except Exception as err: print(err) From 637159012cf3915511decd6742bc73b074d09e1d Mon Sep 17 00:00:00 2001 From: RandomGitUser321 Date: Wed, 26 Jun 2024 19:01:41 -0400 Subject: [PATCH 3/4] Update web_demo_2.5.py --- web_demo_2.5.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web_demo_2.5.py b/web_demo_2.5.py index 94780c7a..9bfa39e9 100644 --- a/web_demo_2.5.py +++ b/web_demo_2.5.py @@ -150,7 +150,8 @@ def chat(img, msgs, ctx, params=None, vision_hidden_states=None): res = res.replace('', '') res = res.replace('', '') answer = res.replace('', '') - torch.cuda.empty_cache() + if device == "cuda": + torch.cuda.empty_cache() return 0, answer, None, None except Exception as err: print(err) From 481426600df94cd5d5cc6a576d63d61f16c81099 Mon Sep 17 00:00:00 2001 From: RandomGitUser321 Date: Wed, 26 Jun 2024 19:01:55 -0400 Subject: [PATCH 4/4] Update web_demo.py --- web_demo.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web_demo.py b/web_demo.py index eae8c54e..9c9cb2f8 100644 --- a/web_demo.py +++ b/web_demo.py @@ -158,7 +158,8 @@ def chat(img, msgs, ctx, params=None, vision_hidden_states=None): res = res.replace('', '') res = res.replace('', '') answer = res.replace('', '') - torch.cuda.empty_cache() + if device == "cuda": + torch.cuda.empty_cache() return 0, answer, None, None except Exception as err: print(err)