djl icon indicating copy to clipboard operation
djl copied to clipboard

how to limit OnnxRuntime cpu usage?

Open leepengcheng opened this issue 1 year ago • 1 comments
trafficstars

Description

I have set interOpNumThreads and intraOpNumThreads option,but the cpu usage is 3200%, it's to high. so how to reduce the cpu usage ,such as 400%.

Code

    val criteria = Criteria.builder
      .optApplication(Application.NLP.TEXT_CLASSIFICATION)
      .optModelUrls(model_path)
      .setTypes(classOf[Longs], classOf[Floats])
      .optTranslator(new BertTranslator())
      .optEngine("OnnxRuntime")
      .optOption("interOpNumThreads", "1")
      .optOption("intraOpNumThreads", "1")
      .optOption("executionMode", "SEQUENTIAL")
      .optOption("optLevel", "NO_OPT")
      .optOption("memoryPatternOptimization", "true")
      .optOption("cpuArenaAllocator", "false")
      .optOption("disablePerSessionThreads", "true")
      .build

Cpu

image

leepengcheng avatar May 08 '24 07:05 leepengcheng

If you send NUM_OMP_THREADS=1, it should only use 1 CPU at a time. How many java thread are you using for inference?

frankfliu avatar May 09 '24 00:05 frankfliu