Skip to content

Commit

Permalink
Tests: improve memory usage (#1147)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewdouglas authored Apr 2, 2024
1 parent 494de20 commit bed0860
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import gc

import pytest
import torch

Expand All @@ -20,6 +22,13 @@ def pytest_runtest_call(item):
raise


@pytest.hookimpl(trylast=True)
def pytest_runtest_teardown(item, nextitem):
gc.collect()
if torch.cuda.is_available():
torch.cuda.empty_cache()


@pytest.fixture(scope="session")
def requires_cuda() -> bool:
cuda_available = torch.cuda.is_available()
Expand Down

0 comments on commit bed0860

Please sign in to comment.