From 9be3580ab3a9efefab6da773da40ca8446df4a82 Mon Sep 17 00:00:00 2001 From: Pierre Chapuis Date: Mon, 24 Jun 2024 16:27:30 +0200 Subject: [PATCH] avoid OOMs in SAM tests --- tests/foundationals/segment_anything/conftest.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/foundationals/segment_anything/conftest.py b/tests/foundationals/segment_anything/conftest.py index bbc8e59..66d19a4 100644 --- a/tests/foundationals/segment_anything/conftest.py +++ b/tests/foundationals/segment_anything/conftest.py @@ -1,9 +1,17 @@ +import gc from pathlib import Path from warnings import warn from pytest import fixture, skip +@fixture(autouse=True) +def ensure_gc(): + # Avoid GPU OOMs + # See https://github.com/pytest-dev/pytest/discussions/8153#discussioncomment-214812 + gc.collect() + + @fixture(scope="package") def ref_path(test_sam_path: Path) -> Path: return test_sam_path / "test_sam_ref"