How to store data to torch.multiprocessing.Manager().list or dict in multiprocessing

Hi,

The following code shows the variable ‘data’ doesn’t store any updated data.
How can I make it updated?

Thanks!

import torch
import torch.multiprocessing as mp
from torch.distributed import init_process_group, destroy_process_group

def func(local_rank, data):
     torch.cuda.set_device(local_rank)
     init_process_group( backend="nccl", rank=local_rank, world_size=2, init_method="tcp://localhost:12355" )
     data[local_rank]["a"] = [1,2,3,4,5]
     print("local_rank=", local_rank, ", data=", data[local_rank]) # prints {}
     destroy_process_group()

if __name__ == "__main__":
     with mp.Manager() as mgr:
          data = mgr.list([{},{}])
          mp.spawn(func, nprocs=2, args=(data,))
          print(data) # prints [{},{}]