faulthandler模块
当我们遇到python解释器崩溃或由于其他未知原因导致无法提供有用的回溯信号时,例如:
模型在训练的时候停止并仅打印:segmentation fault(core dumped)
例如,如果你的程序由于段错误(segfault)或者堆栈溢出而崩溃,那么faulthandler就能提供有用的信息来帮助你找出问题所在。
参考方案:ps -aux | grep python 查看是否有太多进程
排查方法
way1:
python -X faulthandler your_script.py
way2:
利用python3的faulthandler,可定位到出错的代码行
在python代码开头:
import faulthandler
faulthandler.enable()
# 后边正常写你的代码
res = 1 / 0