The “freeze_support()“ line can be omitted if the program is not going to be frozen to prod解决方法
程序员文章站
2024-01-01 10:29:34
...
如下所示报错完整信息
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()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.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()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
解决方法其实很简单,在你的报错信息往上找到属于你代码报错的那一行(那些pytorch等自带的报错行直接忽略),在要运行的代码前面加上:
if __name__ == '__main__':
代码就可以正常运行了。
推荐阅读
-
The “freeze_support()“ line can be omitted if the program is not going to be frozen to prod解决方法
-
Python:The “freeze_support()“ line can be omitted if the program is not going to be frozen
-
The “freeze_support()“ line can be omitted if the program is not going to be frozen to produ
-
PyTorch:The “freeze_support()“ line can be omitted if the program is not going to be frozen
-
PyTorch:The “freeze_support()” line can be omitted if the program is not going to be frozen