Skip to content

Commit 03149cc

Browse files
henrylhtsangfacebook-github-bot
authored andcommitted
check world size and torch.cuda.device_count() in unit tests to try to fix contbuild (#1919)
Summary: Pull Request resolved: #1919 Reviewed By: sarckk Differential Revision: D56448451 fbshipit-source-id: 2dd47f7c26e4a329278c640f8ace084b9789127e
1 parent 76e854c commit 03149cc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

torchrec/distributed/test_utils/multi_process.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(
3838
self.backend = backend
3939
self.local_size = local_size
4040

41-
if torch.cuda.is_available():
41+
if torch.cuda.is_available() and world_size <= torch.cuda.device_count():
4242
self.device: torch.device = torch.device(f"cuda:{rank}")
4343
torch.cuda.set_device(self.device)
4444

0 commit comments

Comments
 (0)