Skip to content

Commit 5b03675

Browse files
committed
fix(cb): make sure memory is freed when calling stop
1 parent bb0a0ce commit 5b03675

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/transformers/generation/continuous_batching/continuous_api.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,12 @@ def stop(self, block: bool = True, timeout: Optional[float] = None) -> None:
826826
if block:
827827
self.join(stop_trigger_time, timeout)
828828

829+
torch.cuda.synchronize()
830+
import gc
831+
832+
gc.collect()
833+
torch.cuda.empty_cache()
834+
829835
def join(self, stop_trigger_time: float, timeout: Optional[float] = None) -> None:
830836
"""Wait for the background thread to finish.
831837

0 commit comments

Comments
 (0)