Skip to content

Commit b8d38dd

Browse files
ScottToddrraminen
andauthored
[release/2.9] Fix test OOMs triggered by test_cuda.py (#2816)
Cherry-pick of pytorch@e4ffd71 > This PR fixes a bug in the `test_garbage_collect_expandable` unit test where the finally block incorrectly re-reads the current per process memory fraction instead of setting the original value. With out the fix the other tests in the `test/test_cuda.py` test suite were impacted and failed with OOM error on ROCm. > > This ensures proper cleanup and isolation of test state, maintaining test correctness and avoiding side effects like the below OOM error that it caused. Progress on ROCm/TheRock#2118 Co-authored-by: rraminen <[email protected]>
1 parent 10201d7 commit b8d38dd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

test/test_cuda.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4408,7 +4408,7 @@ def alloc(n):
44084408
# expandable_segment blocks can be in the free list when this is called.
44094409
alloc(80)
44104410
finally:
4411-
orig = torch.cuda.get_per_process_memory_fraction(0)
4411+
torch.cuda.memory.set_per_process_memory_fraction(orig)
44124412

44134413
def test_allocator_settings(self):
44144414
def power2_div(size, div_factor):

0 commit comments

Comments
 (0)