在使用pytorch训练模型时,遇到了这样的错误:
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
..

在Windows系统中使用PyTorch训练模型时遇到RuntimeError,提示不能在非fork环境下启动新进程。错误原因在于DataLoader的num_workers设置不正确。解决方案是将num_workers设置为0,确保在Windows上避免使用多进程加载数据。修改配置后,问题得以解决。
最低0.47元/天 解锁文章
2285





