Skip to content

Commit 8225e77

Browse files
eqypytorchmergebot
authored andcommitted
[CUDA][Expandable Segments] Account for non-gc'able memory in expandable segments tests (pytorch#136496)
Seems like some other tests are holding onto memory that is not gc'able (e.g., cuBLAS workspaces), so these tests while working in isolation fail when run as e.g., `python test/test_cuda.py -k able` Pull Request resolved: pytorch#136496 Approved by: https://github.com/ezyang
1 parent 5233b5a commit 8225e77

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test/test_cuda.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -3579,7 +3579,8 @@ def test_max_split_expandable(self):
35793579
torch.cuda.memory.empty_cache()
35803580
mb = 1024 * 1024
35813581
_, all_memory = torch.cuda.memory.mem_get_info()
3582-
total_allowed = 120 * mb
3582+
pre_reserved = torch.cuda.memory_reserved()
3583+
total_allowed = 120 * mb + pre_reserved
35833584
fraction_allowed = total_allowed / all_memory
35843585
assert int(fraction_allowed * all_memory) == total_allowed
35853586
torch.cuda.memory.set_per_process_memory_fraction(fraction_allowed)
@@ -3609,7 +3610,8 @@ def test_garbage_collect_expandable(self):
36093610
torch.cuda.memory.empty_cache()
36103611
mb = 1024 * 1024
36113612
_, all_memory = torch.cuda.memory.mem_get_info()
3612-
total_allowed = 120 * mb
3613+
pre_reserved = torch.cuda.memory_reserved()
3614+
total_allowed = 120 * mb + pre_reserved
36133615
fraction_allowed = total_allowed / all_memory
36143616
assert int(fraction_allowed * all_memory) == total_allowed
36153617
torch.cuda.memory.set_per_process_memory_fraction(fraction_allowed)

0 commit comments

Comments
 (0)