Hi,
I am trying to use the torch.multiprocessing tool. However, it seems not working with the tensors who need grad. A cpu version code is shown below. Do you have any suggestions? (p.s. I have only one single GPU, one 8-core CPU and want to do parallel computation,  but I see most of the tutorials are working on multiGPU using multiprocessing.)
Code:
import torch.multiprocessing as mp
import torch
def job(num):
    return num * 2


if __name__ == '__main__':
    p = mp.Pool(processes=20)
    a = [torch.tensor(float(i), requires_grad=True) for i in range(20)]
    # a = [torch.tensor(float(i), requires_grad=False) for i in range(20)] # works

    data = p.map(job, a)
    p.close()
    print(data)
    datatorch = torch.stack(data)
    print(datatorch)
    l = datatorch - datatorch / 2.0
    print(l)


Error:

MaybeEncodingError: Error sending result: ‘[tensor(0., grad_fn=)]’. Reason: ‘RuntimeError(‘Cowardly refusing to serialize non-leaf tensor which requires_grad, since autograd does not support crossing process boundaries.  If you just want to transfer the data, call detach() on the tensor before serializing (e.g., putting it on the queue).’,)’