Skip to content

Commit d1cf549

Browse files
committed
remove gc collect again for now
1 parent 3075f5b commit d1cf549

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

users/zeyer/experiments/exp2024_04_23_baselines/ctc_recog_ext.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,6 @@ def model_recog_flashlight(
457457
out_spatial_dim,
458458
final beam_dim
459459
"""
460-
import gc
461460
from dataclasses import dataclass
462461
import torch
463462
from flashlight.lib.text.decoder import LM, LMState
@@ -598,7 +597,9 @@ def _cache_maybe_free_memory(self):
598597
if used_mem / total_mem < self._max_used_mem_fraction:
599598
break
600599
# Check again after trying to empty the cache.
601-
gc.collect()
600+
# Note: gc.collect() is problematic here because of how Flashlight handles the states:
601+
# We have millions of Python objects in the mapping_states dict,
602+
# which takes a very long time to go through.
602603
torch.cuda.empty_cache()
603604
used_mem = torch.cuda.memory_reserved(dev)
604605
if used_mem / total_mem < self._max_used_mem_fraction:

0 commit comments

Comments
 (0)