From 19bc08165863aa663c43c467c07123718bc44cd1 Mon Sep 17 00:00:00 2001 From: Pierre Chapuis Date: Mon, 29 Jan 2024 14:38:17 +0100 Subject: [PATCH] call GC between each e2e test to avoid OOM --- tests/e2e/test_diffusion.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/e2e/test_diffusion.py b/tests/e2e/test_diffusion.py index d59c627..0e1a6c5 100644 --- a/tests/e2e/test_diffusion.py +++ b/tests/e2e/test_diffusion.py @@ -1,3 +1,4 @@ +import gc from pathlib import Path from typing import Iterator from warnings import warn @@ -30,6 +31,13 @@ from refiners.foundationals.latent_diffusion.stable_diffusion_xl.model import St from tests.utils import ensure_similar_images +@pytest.fixture(autouse=True) +def ensure_gc(): + # Avoid GPU OOMs + # See https://github.com/pytest-dev/pytest/discussions/8153#discussioncomment-214812 + gc.collect() + + @pytest.fixture(scope="module") def ref_path(test_e2e_path: Path) -> Path: return test_e2e_path / "test_diffusion_ref"