Skip to content

Commit

Permalink
silero: fix high cpu usage (livekit#569)
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom authored Aug 3, 2024
1 parent 8ce90df commit 4e346c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/red-numbers-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-plugins-silero": patch
---

silero: fix high cpu usage
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ def new_inference_session(force_cpu: bool) -> onnxruntime.InferenceSession:
path = str(_resource_files.enter_context(ctx))

opts = onnxruntime.SessionOptions()
opts.add_session_config_entry("session.intra_op.allow_spinning", "0")
opts.add_session_config_entry("session.inter_op.allow_spinning", "0")
opts.inter_op_num_threads = 1
opts.intra_op_num_threads = 1
opts.graph_optimization_level = onnxruntime.GraphOptimizationLevel.ORT_ENABLE_ALL
opts.execution_mode = onnxruntime.ExecutionMode.ORT_SEQUENTIAL

if force_cpu and "CPUExecutionProvider" in onnxruntime.get_available_providers():
session = onnxruntime.InferenceSession(
path, providers=["CPUExecutionProvider"], ess_options=opts
path, providers=["CPUExecutionProvider"], sess_options=opts
)
else:
session = onnxruntime.InferenceSession(path, sess_options=opts)
Expand Down

0 comments on commit 4e346c0

Please sign in to comment.