Fix SAM OOM issue on CI (#24125)

fix

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
Yih-Dar 2023-06-09 15:07:08 +02:00 committed by GitHub
parent 707023d155
commit b8fe259f16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -15,6 +15,7 @@
""" Testing suite for the PyTorch SAM model. """
import gc
import inspect
import unittest
@ -461,6 +462,12 @@ def prepare_dog_img():
@slow
class SamModelIntegrationTest(unittest.TestCase):
def tearDown(self):
super().tearDown()
# clean-up as much as possible GPU memory occupied by PyTorch
gc.collect()
torch.cuda.empty_cache()
def test_inference_mask_generation_no_point(self):
model = SamModel.from_pretrained("facebook/sam-vit-base")
processor = SamProcessor.from_pretrained("facebook/sam-vit-base")

View File

@ -17,6 +17,7 @@
from __future__ import annotations
import gc
import inspect
import unittest
@ -429,6 +430,11 @@ def prepare_dog_img():
@slow
class SamModelIntegrationTest(unittest.TestCase):
def tearDown(self):
super().tearDown()
# clean-up as much as possible GPU memory occupied by PyTorch
gc.collect()
def test_inference_mask_generation_no_point(self):
model = TFSamModel.from_pretrained("facebook/sam-vit-base")
processor = SamProcessor.from_pretrained("facebook/sam-vit-base")