Skip to content

Commit

Permalink
check world size and torch.cuda.device_count() in unit tests to try t…
Browse files Browse the repository at this point in the history
…o fix contbuild (pytorch#1919)

Summary: Pull Request resolved: pytorch#1919

Differential Revision: D56448451
  • Loading branch information
henrylhtsang authored and facebook-github-bot committed Apr 23, 2024
1 parent 183f5a7 commit 3b817cb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion torchrec/distributed/test_utils/multi_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(
self.backend = backend
self.local_size = local_size

if torch.cuda.is_available():
if torch.cuda.is_available() and world_size <= torch.cuda.device_count():
self.device: torch.device = torch.device(f"cuda:{rank}")
torch.cuda.set_device(self.device)

Expand Down

0 comments on commit 3b817cb

Please sign in to comment.