Implement gc.collect() to free memory (#10129)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
Glenn Jocher 2024-04-17 19:37:40 -07:00 committed by GitHub
parent 37ffebd690
commit 1f4bed233a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 0 deletions

View file

@ -50,6 +50,7 @@ TensorFlow.js:
$ npm start
"""
import gc
import json
import os
import shutil
@ -713,6 +714,7 @@ class Exporter:
# Free CUDA memory
del self.model
gc.collect()
torch.cuda.empty_cache()
# Write file