Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions test/test_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -5045,12 +5045,16 @@ def test_throw_on_cudamalloc_oom(self):
# preemptively rejected with OutOfMemoryError.
# Both settings must go through _accelerator_setAllocatorSettings so
# they are read from CUDAAllocatorConfig.
fraction = 0.005
torch._C._accelerator_setAllocatorSettings(
"throw_on_cudamalloc_oom:True,per_process_memory_fraction:0.01"
f"throw_on_cudamalloc_oom:True,per_process_memory_fraction:{fraction}"
)

total_mem = torch.cuda.get_device_properties(0).total_memory
# Allocate the allowed threshold + 1 MiB to guarantee rejection
alloc_bytes = int(total_mem * fraction) + 1024 * 1024
with self.assertRaises(torch.cuda.OutOfMemoryError):
torch.empty(1024 * 1024 * 1024, dtype=torch.int8, device="cuda")
torch.empty(alloc_bytes, dtype=torch.int8, device="cuda")

# Check that rejection counter was incremented
stats = torch.cuda.memory_stats()
Expand Down
1 change: 1 addition & 0 deletions test/test_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,7 @@ def test_cpp_warnings_have_python_context(self, device):
s = ".+Triggered internally at.+RangeFactories.+"
# nvfuser deprecation warning filter
warnings.filterwarnings("ignore", "torch::jit::fuser::cuda", UserWarning)
warnings.filterwarnings("ignore", ".*", DeprecationWarning) # ignore all deprecation warnings

def cpp_warn_fn():
out = torch.empty((5,))
Expand Down