Avoid OOM when other tests are failing (#39758)

fix

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
Yih-Dar
2025-07-29 15:35:44 +02:00
committed by GitHub
parent 65df73aa88
commit dfd616e658

View File

@@ -31,6 +31,7 @@ from transformers import (
)
from transformers.testing_utils import (
Expectations,
cleanup,
get_device_properties,
is_torch_available,
is_torchaudio_available,
@@ -1256,6 +1257,12 @@ class MusicgenMelodyIntegrationTests(unittest.TestCase):
def model(self):
return MusicgenMelodyForConditionalGeneration.from_pretrained("ylacombe/musicgen-melody").to(torch_device)
def setUp(self):
cleanup(torch_device, gc_collect=True)
def tearDown(self):
cleanup(torch_device, gc_collect=True)
@cached_property
def processor(self):
return MusicgenMelodyProcessor.from_pretrained("ylacombe/musicgen-melody")