zmeeks commited on
Commit
019c212
·
verified ·
1 Parent(s): 6492713

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -154,8 +154,10 @@ class BasicAgent:
154
  def cleanup_memory():
155
  """Centralized memory cleanup function"""
156
  if torch.cuda.is_available():
157
- torch.cuda.empty_cache()
158
  torch.cuda.synchronize()
 
 
 
159
  gc.collect()
160
 
161
 
@@ -214,7 +216,6 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
214
  answers_payload = []
215
  print(f"Running agent on {len(questions_data)} questions...")
216
  for item in questions_data:
217
- cleanup_memory()
218
  task_id = item.get("task_id")
219
  question_text = item.get("question")
220
  if not task_id or question_text is None:
@@ -224,6 +225,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
224
  submitted_answer = agent(question_text)
225
  answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
226
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
 
227
  except Exception as e:
228
  print(f"Error running agent on task {task_id}: {e}")
229
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
 
154
  def cleanup_memory():
155
  """Centralized memory cleanup function"""
156
  if torch.cuda.is_available():
 
157
  torch.cuda.synchronize()
158
+ torch.cuda.empty_cache()
159
+ import time
160
+ time.sleep(0.1)
161
  gc.collect()
162
 
163
 
 
216
  answers_payload = []
217
  print(f"Running agent on {len(questions_data)} questions...")
218
  for item in questions_data:
 
219
  task_id = item.get("task_id")
220
  question_text = item.get("question")
221
  if not task_id or question_text is None:
 
225
  submitted_answer = agent(question_text)
226
  answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
227
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
228
+ cleanup_memory()
229
  except Exception as e:
230
  print(f"Error running agent on task {task_id}: {e}")
231
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})