Many thanks @iffiX for input on this. I am new to torch.multiprocessing.spawn and PyTorch in general, so I guess I just got confused when I read the documentation on it.

With your first point above, are you missing args=()?, ie.

if __name__ == '__main__':
    # start with 4 processes
    # your original method will invoke your function as X_power_func(0, 0, 1, 2, 3)
    spawn(X_power_func, args=(0, 1, 2, 3), nprocs=4)

I don’t understand why must we start with 4 processes?


With your second point, if the results are kept within main, how would I then output the results outside of main?


With your third point, can I ask what is ProcessContext? If I want to return results, does that mean I need to set join=False?


I am sorry for having so many questions. Would really be grateful if you could help.