I figure out using torch.multiprocessing.set_start_method('spawn') causes the problem. My code runs with no problem on cpu, when i do not set this. However, i believe this is necessary to be set for when i use cuda, right?