Skip to content

Instantly share code, notes, and snippets.

@toshihikoyanase
Created February 3, 2021 05:52
Show Gist options
  • Save toshihikoyanase/27350c587b40335fccf012e108eb6b93 to your computer and use it in GitHub Desktop.
Save toshihikoyanase/27350c587b40335fccf012e108eb6b93 to your computer and use it in GitHub Desktop.
Cannot broadcast bool tensor.
import torch
import torch.distributed as dist
import torch.multiprocessing as mp
def example(rank, world_size):
dist.init_process_group("gloo", rank=rank, world_size=world_size)
if rank == 0:
z = torch.tensor([True], dtype=torch.bool)
else:
z = torch.empty(1, dtype=torch.bool)
dist.broadcast(z, 0)
def main():
world_size = 2
mp.spawn(example,
args=(world_size,),
nprocs=world_size,
join=True)
print("Done")
if __name__=="__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment