Skip to content

Commit 7c88219

Browse files
committed
fix: try with memory cleaning
1 parent 3cb18e5 commit 7c88219

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

benchmarks/run_benchmark.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import gc
12
import os
23
import time
34

@@ -73,6 +74,8 @@ def run_cusadi_benchmark(fn, inputs):
7374
results["N_EVALS"] = N_EVALS
7475

7576
for fn in benchmark_fns:
77+
with torch.no_grad():
78+
torch.cuda.empty_cache()
7679
fn_name = fn.name()
7780
for i, n_envs in enumerate(N_ENVS_SWEEP):
7881
print(f"Running CUDA benchmark for {n_envs} environments with function {fn_name}...")
@@ -128,6 +131,7 @@ def main():
128131
if PathsProvider.RUN_CUSADI:
129132
cuda_results = run_cuda_benchmarks()
130133
np.savez(f"{cur_dir}/cuda_benchmark_results.npz", **cuda_results)
134+
gc.collect()
131135

132136
jaxadi_results = run_jaxadi_benchmarks()
133137
np.savez(f"{cur_dir}/jaxadi_benchmark_results.npz", **jaxadi_results)

0 commit comments

Comments
 (0)