wenet-e2e / wenet

Production First and Production Ready End-to-End Speech Recognition Toolkit
https://wenet-e2e.github.io/wenet/
Apache License 2.0
4.08k stars 1.07k forks source link

fix segmentfault in (#2506) #2530

Closed MengqingCao closed 4 months ago

MengqingCao commented 4 months ago

解决Kunpeng cpu上 segmentfault 的同时,避免了 deepspeed 的重复初始化。 只粗略定位到是数据集处理模块 processor.py 中存在多线程处理的操作,造成了多进程读取数据时的死锁问题。因此在 processor 开始处设置线程数为1,来防止死锁和 segmentfault

为防止侵入式修改,在读取 cpu 硬件信息判断为 Kunpeng 后才进行此修改。

    # set number of threads in the subprocesses to 1
    # Why? There may be some operators ultilizing multi-threads in processor,
    # causing possibly deadlock in Kunpeng.
    # Similar issue in PyTorch: https://github.com/pytorch/pytorch/issues/45198
MengqingCao commented 4 months ago

@xingchensong 感谢神速review,麻烦验证下在你的diy代码上是否还有影响:-)

xingchensong commented 4 months ago

@xingchensong 感谢神速review,麻烦验证下在你的diy代码上是否还有影响:-)

ok

Mddct commented 4 months ago

有个openmp的环境变量 把那个thread 设置成2 试下

另外 是processor中哪个用来多线程?

MengqingCao commented 4 months ago

有个openmp的环境变量 把那个thread 设置成2 试下

试了下这个,也是会导致段错误,只有设置线程数为1才能避免这个问题。 另外,我没有排查到具体是哪个算子用到了多线程,processor 里涉及的操作比较多,而且我的程序直接 crash 掉,堆栈中没有获得有效信息。pytorch 社区有关类似问题的讨论中,查阅到的只有 opencv 和 open3D 中的算子会导致相同的问题: https://github.com/pytorch/pytorch/issues/45198

image

xingchensong commented 4 months ago

it works, thx

Mddct commented 4 months ago

有个openmp的环境变量 把那个thread 设置成2 试下

试了下这个,也是会导致段错误,只有设置线程数为1才能避免这个问题。 另外,我没有排查到具体是哪个算子用到了多线程,processor 里涉及的操作比较多,而且我的程序直接 crash 掉,堆栈中没有获得有效信息。pytorch 社区有关类似问题的讨论中,查阅到的只有 opencv 和 open3D 中的算子会导致相同的问题: https://github.com/pytorch/pytorch/issues/45198

image

帮忙benchmark下速度, dataset这一块 因为torchaudio 以及torch的tensor操作 有的是并行的

xingchensong commented 4 months ago

有个openmp的环境变量 把那个thread 设置成2 试下

试了下这个,也是会导致段错误,只有设置线程数为1才能避免这个问题。 另外,我没有排查到具体是哪个算子用到了多线程,processor 里涉及的操作比较多,而且我的程序直接 crash 掉,堆栈中没有获得有效信息。pytorch 社区有关类似问题的讨论中,查阅到的只有 opencv 和 open3D 中的算子会导致相同的问题: pytorch/pytorch#45198 image

帮忙benchmark下速度, dataset这一块 因为torchaudio 以及torch的tensor操作 有的是并行的

这个只影响kunpeng cpu,intel cpu不会进入设置thread那个if分支