djl
djl copied to clipboard
how to limit OnnxRuntime cpu usage?
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
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?