HIT-SCIR / ltp

Language Technology Platform
http://ltp.ai
4.96k stars 1.04k forks source link

如何关闭ltp默认的多进程 #536

Open LimKim opened 3 years ago

LimKim commented 3 years ago

ltp进行批处理时,会占满所有cpu核,怎么在ltp内部通过参数控制单进程

AlongWY commented 3 years ago

这个应该是无GPU情况下,pytorch 的默认行为,之后看一下有什么办法解决

sralvins commented 2 years ago

有解决方法了吗

sralvins commented 2 years ago

I added a few lines of code at the beginning of the ltp/__init__.py :

import torch
torch.set_num_threads(1)

it works. 但我还是不清楚哪里开启的多线程 maybe introduced in torchscript inference.