Thanks a lot for the help so far . After adding torch.multiprocessing .set_start_method(“spawn”), there arise a new problem:
Traceback (most recent call last):
  File "test9.py", line 45, in <module>
    torch.multiprocessing.set_start_method('spawn')
  File "/usr/local/lib/python3.5/multiprocessing/context.py", line 231, in set_start_method
    raise RuntimeError('context has already been set')
RuntimeError: context has already been set


Is there a way around this ?