Skip to content

Commit

Permalink
Merge pull request #298 from Harushii18/patch-1
Browse files Browse the repository at this point in the history
Fix musigen app memory issue
  • Loading branch information
felixkreuk authored Nov 23, 2023
2 parents c65e9be + 201b542 commit 95f2747
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions demos/musicgen_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ def _cleanup(self):
self.files.pop(0)
else:
break



file_cleaner = FileCleaner()


Expand All @@ -96,6 +95,9 @@ def load_model(version='facebook/musicgen-melody'):
global MODEL
print("Loading model", version)
if MODEL is None or MODEL.name != version:
# Clear PyTorch CUDA cache and delete model
del MODEL
torch.cuda.empty_cache()
MODEL = None # in case loading would crash
MODEL = MusicGen.get_pretrained(version)

Expand Down

0 comments on commit 95f2747

Please sign in to comment.