ltp icon indicating copy to clipboard operation
ltp copied to clipboard

如何关闭ltp默认的多进程

Open LimKim opened this issue 2 years ago • 3 comments

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

LimKim avatar Aug 24 '21 03:08 LimKim

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

AlongWY avatar Sep 30 '21 08:09 AlongWY

有解决方法了吗

sralvins avatar Nov 25 '21 07:11 sralvins

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.

sralvins avatar Nov 25 '21 08:11 sralvins