Skip to content

Commit 5b9b816

Browse files
ezyangpytorchmergebot
authored andcommitted
WAR by avoid querying device before env mutation (#107301)
We should probably fix #107300 properly but this works around the problem Signed-off-by: Edward Z. Yang <[email protected]> Pull Request resolved: #107301 Approved by: https://github.com/bdhirsh, https://github.com/H-Huang, https://github.com/albanD
1 parent b234b94 commit 5b9b816

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

benchmarks/dynamo/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3002,9 +3002,12 @@ def main(runner, original_dir=None):
30023002
f"--diff-branch: current branch is same as {args.diff_branch} branch, what are you diffing?"
30033003
)
30043004

3005-
device_count = torch.cuda.device_count()
30063005
args.use_distributed = (args.ddp or args.fsdp) and args.only
30073006
if args.multiprocess:
3007+
# NB: Do NOT query device count before CUDA initialization; we're
3008+
# going to overwrite CUDA_VISIBLE_DEVICES and this will result in
3009+
# https://github.com/pytorch/pytorch/issues/107300
3010+
device_count = torch.cuda.device_count()
30083011
if device_count <= 1:
30093012
log.warning(
30103013
"The use multiprocess flag is set but there are <= 1 devices available."

0 commit comments

Comments
 (0)