Skip to content

Commit 645fc33

Browse files
committed
saving logs to benchmark_tmp.csv instead of benchmark.csv and gitignore _tmp.csv; better try/catch if missing ACCESS TOKEN
1 parent 5245735 commit 645fc33

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
model_zoo/
22
outputs/
3+
*benchmark_tmp.csv
34

45
# Byte-compiled / optimized / DLL files
56
__pycache__/

scripts/benchmark.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ def run_benchmark_grid(grid, n_repeats, num_inference_steps):
134134
* n_repeats: nb datapoints for inference latency benchmark
135135
"""
136136

137-
csv_fpath = pathlib.Path(__file__).parent.parent / "benchmark.csv"
137+
csv_fpath = pathlib.Path(__file__).parent.parent / "benchmark_tmp.csv"
138138
# create benchmark.csv if not exists
139139
if not os.path.isfile(csv_fpath):
140140
header = ["device", "precision", "n_samples", "latency", "memory"]
141141
with open(csv_fpath, "w") as f:
142142
writer = csv.writer(f)
143143
writer.writerow(header)
144144

145-
# append new benchmark results to it if benchmark.csv already exists
145+
# append new benchmark results to it if benchmark_tmp.csv already exists
146146
with open(csv_fpath, "a") as f:
147147
writer = csv.writer(f)
148148
device_desc = get_device_description()
@@ -158,13 +158,15 @@ def run_benchmark_grid(grid, n_repeats, num_inference_steps):
158158
num_inference_steps=num_inference_steps
159159
)
160160
except Exception as e:
161-
print(str(e))
162161
if "CUDA out of memory" in str(e) or "Failed to allocate memory" in str(e):
162+
print(str(e))
163163
torch.cuda.empty_cache()
164164
new_log = {
165165
"latency": -1.00,
166166
"memory": -1.00
167167
}
168+
else:
169+
raise e
168170

169171
latency = new_log["latency"]
170172
memory = new_log["memory"]

0 commit comments

Comments
 (0)