查了网上说的教程,说是

When using spawn you should guard the part that launches the job in if __name__ == '__main__':

set_start_method should also go there, and everything will run fine.

所以把任务放到了if __name__ == '__main__':下面

RuntimeError: context has already been set(multiprocessing)_系统

后面有人说

You might have other files in your project which also have a if __name__ == '__main__':. One workaround is to call the set_start_method with the force argument as: set_start_method('forkserver', force=True). This solved the issue for me.


又改成了multiprocessing.set_start_method('forkserver', force=True)


RuntimeError: context has already been set(multiprocessing)_系统_02

可算是跑起来了