-
Notifications
You must be signed in to change notification settings - Fork 705
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
easybuild/easyconfigs/p/PyTorch/PyTorch-1.12.1_fix-autograd-thread_shutdown-test.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Fix flaky test_thread_shutdown in test_autograd | ||
|
||
From https://github.com/pytorch/pytorch/pull/86464 | ||
|
||
Backport: Alexander Grund (TU Dresden) | ||
|
||
diff --git a/test/test_autograd.py b/test/test_autograd.py | ||
index da1e859682e..0c0bc4f1a2a 100644 | ||
--- a/test/test_autograd.py | ||
+++ b/test/test_autograd.py | ||
@@ -4320,8 +4320,12 @@ class MyFunction(Function): | ||
def backward(ctx, grad): | ||
return grad | ||
|
||
+# Run on cuda if it is available to ensure that the worker thread | ||
+# is properly initialized by the time we exit. | ||
+device = "cuda" if torch.cuda.is_available() else "cpu" | ||
+ | ||
for shape in [(1,), ()]: | ||
- v = torch.ones(shape, requires_grad=True) | ||
+ v = torch.ones(shape, requires_grad=True, device=device) | ||
MyFunction.apply(v).backward() | ||
""" | ||
s = TestCase.runWithPytorchAPIUsageStderr(code) |