The “freeze_support()“ line can be omitted if the program i

深碍√TFBOYSˉ_ 2022-10-16 09:56 352阅读 0赞

转自

PyTorch错误:The “freeze_support()” line can be omitted if the program is not going to be frozen to produce an executable.

错误代码如下:

  1. RuntimeError:
  2. An attempt has been made to start a new process before the
  3. current process has finished its bootstrapping phase.
  4. This probably means that you are not using fork to start your
  5. child processes and you have forgotten to use the proper idiom
  6. in the main module:
  7. if __name__ == '__main__':
  8. freeze_support()
  9. ...
  10. The "freeze_support()" line can be omitted if the program
  11. is not going to be frozen to produce an executable.RuntimeError:
  12. An attempt has been made to start a new process before the
  13. current process has finished its bootstrapping phase.
  14. This probably means that you are not using fork to start your
  15. child processes and you have forgotten to use the proper idiom
  16. in the main module:
  17. if __name__ == '__main__':
  18. freeze_support()
  19. ...
  20. The "freeze_support()" line can be omitted if the program
  21. is not going to be frozen to produce an executable.

解决方法

将你要运行的代码块放到main函数中运行即可

  1. if __name__ == '__main__':
  2. #your code

发表评论

表情:
评论列表 (有 0 条评论,352人围观)

还没有评论,来说两句吧...

相关阅读