window python 主函数 写 if __name__ == "__main__": 可以避免多进程等错误(训练yolov8时出现的)
2024-10-20 08:41:30
训练yolov8时出现
类似以下错误:
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.
大概意思是 linux 是用 fork,windows 是用spawn,spawn要加 if __name__ == "__main__": 区分主进程。
参考:Python 中的多线程和多进程(上) - 知乎 (zhihu.com)
最新文章
- 利用Dockerfile构建一个基于centos 7,包括java 8, tomcat 7,php ,mysql+mycat的镜像
- C# 词法分析器(五)转换 DFA
- Python中setuptools做什么用的?
- SGU 455 Sequence analysis(Cycle detection,floyd判圈算法)
- SQL Server 2005 分区表创建实例
- php7+apache的环境安装配置
- HDU5029--Relief grain (树链剖分+线段树 )
- android的fragments管理
- Android在子线程中更新UI(二)
- Hibernate 系列教程4-单向多对一
- vue渐变淡入淡出轮播图
- python之爬虫学习记录与心得
- 微信小程序,前端大梦想(七)
- POJ-1915 Knight Moves (BFS)
- Java---实现邮件发送
- 【源码】HashMap源码及线程非安全分析
- 提取配置文件中无注释的内容方法--findstr
- python3 利用pip命令安装包和模块
- Python3 与 C# 并发编程之~ 线程篇
- VS诊断工具打开失败