Spaces:
Runtime error
Runtime error
yuxj
commited on
Commit
•
a0e96fb
1
Parent(s):
ac20c0f
add gc
Browse files
app.py
CHANGED
@@ -5,6 +5,7 @@ from transformers import AutoTokenizer, AutoModel
|
|
5 |
from duckduckgo_search import ddg
|
6 |
import time
|
7 |
import gradio as gr
|
|
|
8 |
|
9 |
def best_device():
|
10 |
if torch.cuda.is_available():
|
@@ -64,6 +65,7 @@ def ask_question(question, local_content = '', web_content = ''):
|
|
64 |
return response
|
65 |
|
66 |
def on_click(question, kb_types):
|
|
|
67 |
if best_device() == 'cuda':
|
68 |
torch.cuda.empty_cache()
|
69 |
|
@@ -86,6 +88,7 @@ def on_click(question, kb_types):
|
|
86 |
result = ask_question(question, local_content, web_content)
|
87 |
print(f'{result}\n\n----------------------------')
|
88 |
|
|
|
89 |
if best_device() == 'cuda':
|
90 |
torch.cuda.empty_cache()
|
91 |
return result
|
|
|
5 |
from duckduckgo_search import ddg
|
6 |
import time
|
7 |
import gradio as gr
|
8 |
+
import gc
|
9 |
|
10 |
def best_device():
|
11 |
if torch.cuda.is_available():
|
|
|
65 |
return response
|
66 |
|
67 |
def on_click(question, kb_types):
|
68 |
+
gc.collect()
|
69 |
if best_device() == 'cuda':
|
70 |
torch.cuda.empty_cache()
|
71 |
|
|
|
88 |
result = ask_question(question, local_content, web_content)
|
89 |
print(f'{result}\n\n----------------------------')
|
90 |
|
91 |
+
gc.collect()
|
92 |
if best_device() == 'cuda':
|
93 |
torch.cuda.empty_cache()
|
94 |
return result
|