Unverified Commit b8fe259f authored by Yih-Dar's avatar Yih-Dar Committed by GitHub
Browse files

Fix SAM OOM issue on CI (#24125)



fix
Co-authored-by: default avatarydshieh <ydshieh@users.noreply.github.com>
parent 707023d1
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
""" Testing suite for the PyTorch SAM model. """ """ Testing suite for the PyTorch SAM model. """
import gc
import inspect import inspect
import unittest import unittest
...@@ -461,6 +462,12 @@ def prepare_dog_img(): ...@@ -461,6 +462,12 @@ def prepare_dog_img():
@slow @slow
class SamModelIntegrationTest(unittest.TestCase): 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): def test_inference_mask_generation_no_point(self):
model = SamModel.from_pretrained("facebook/sam-vit-base") model = SamModel.from_pretrained("facebook/sam-vit-base")
processor = SamProcessor.from_pretrained("facebook/sam-vit-base") processor = SamProcessor.from_pretrained("facebook/sam-vit-base")
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
from __future__ import annotations from __future__ import annotations
import gc
import inspect import inspect
import unittest import unittest
...@@ -429,6 +430,11 @@ def prepare_dog_img(): ...@@ -429,6 +430,11 @@ def prepare_dog_img():
@slow @slow
class SamModelIntegrationTest(unittest.TestCase): 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): def test_inference_mask_generation_no_point(self):
model = TFSamModel.from_pretrained("facebook/sam-vit-base") model = TFSamModel.from_pretrained("facebook/sam-vit-base")
processor = SamProcessor.from_pretrained("facebook/sam-vit-base") processor = SamProcessor.from_pretrained("facebook/sam-vit-base")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment