Help: cannot pickle 'weakref' object

I tried to set spawn mode in the beginning of my program by

    torch.multiprocessing.set_start_method('spawn')

But when I ran my program, there came an error about ’ cannot pickle ‘weakref’ object’. And it arose at the place where I tried to start multiprocessing function. I thought maybe because the function or args I sent to multiprocessing can’t be pickled. But how can I solve this problem. Thanks!

1 Like

Hi, I’m facing the same error while my line of code is a bit different.
It is as follows - torch.multiprocessing.set_sharing_strategy(‘file_system’).

What is the possible solution to it?