Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's the Vosk CPU usage at run-time? #498

Closed
solyarisoftware opened this issue Apr 19, 2021 · 2 comments
Closed

What's the Vosk CPU usage at run-time? #498

solyarisoftware opened this issue Apr 19, 2021 · 2 comments

Comments

@solyarisoftware
Copy link

Hi,
this is not an issue ora bug, just a info request.

I would like to measure the Vosk CPU usage at runtime, especially for the transcript calls (after the initial model creation).
More in general can I have some info about Vosk CPU usage? It use multi cores if available, right?

BTW, I just realized a simple nodejs wrapper to the Vosk API nodejs binding:
https://github.com/solyarisoftware/voskJs

To transcript an audio file follwing a give model, I run the command line program:

node voskjs --audio=audio/2830-3980-0043.wav --model=models/vosk-model-en-us-aspire-0.2

Now, I want to measure the CPU usage of the above process. I tried to use linux pidstat command, with these result:

$ pidstat 1 -ut -e node voskjs --audio=audio/2830-3980-0043.wav --model=models/vosk-model-en-us-aspire-0.2
Linux 5.8.0-50-generic (giorgio-HP-Laptop-17-by1xxx) 	19/04/2021 	_x86_64_	(8 CPU)

log level          : 0

LOG (VoskAPI:ReadDataFiles():model.cc:194) Decoding params beam=13 max-active=7000 lattice-beam=6
LOG (VoskAPI:ReadDataFiles():model.cc:197) Silence phones 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15
LOG (VoskAPI:RemoveOrphanNodes():nnet-nnet.cc:948) Removed 1 orphan nodes.
LOG (VoskAPI:RemoveOrphanComponents():nnet-nnet.cc:847) Removing 2 orphan components.
LOG (VoskAPI:Collapse():nnet-utils.cc:1488) Added 1 components, removed 2
LOG (VoskAPI:CompileLooped():nnet-compile-looped.cc:345) Spent 0.00647402 seconds in looped compilation.
LOG (VoskAPI:ReadDataFiles():model.cc:221) Loading i-vector extractor from models/vosk-model-en-us-aspire-0.2/ivector/final.ie
LOG (VoskAPI:ComputeDerivedVars():ivector-extractor.cc:183) Computing derived variables for iVector extractor
LOG (VoskAPI:ComputeDerivedVars():ivector-extractor.cc:204) Done.
LOG (VoskAPI:ReadDataFiles():model.cc:246) Loading HCLG from models/vosk-model-en-us-aspire-0.2/graph/HCLG.fst

14:58:23      UID      TGID       TID    %usr %system  %guest   %wait    %CPU   CPU  Command
14:58:24     1000    119364         -   61,00   85,00    0,00    0,00  146,00     0  node
14:58:24     1000         -    119364   18,00   76,00    0,00    0,00   94,00     0  |__node
14:58:24     1000         -    119365    0,00    0,00    0,00    0,00    0,00     0  |__node
14:58:24     1000         -    119366    3,00    0,00    0,00    0,00    3,00     6  |__node
14:58:24     1000         -    119367    3,00    0,00    0,00    0,00    3,00     4  |__node
14:58:24     1000         -    119368    3,00    0,00    0,00    0,00    3,00     0  |__node
14:58:24     1000         -    119369    3,00    0,00    0,00    0,00    3,00     1  |__node
14:58:24     1000         -    119370    0,00    0,00    0,00    0,00    0,00     0  |__node
14:58:24     1000         -    119371    0,00    0,00    0,00    0,00    0,00     0  |__node
14:58:24     1000         -    119372    0,00    0,00    0,00    0,00    0,00     1  |__node
14:58:24     1000         -    119373    0,00    0,00    0,00    0,00    0,00     6  |__node
14:58:24     1000         -    119374    0,00    0,00    0,00    0,00    0,00     0  |__node
LOG (VoskAPI:ReadDataFiles():model.cc:265) Loading words from models/vosk-model-en-us-aspire-0.2/graph/words.txt
LOG (VoskAPI:ReadDataFiles():model.cc:273) Loading winfo models/vosk-model-en-us-aspire-0.2/graph/phones/word_boundary.int
LOG (VoskAPI:ReadDataFiles():model.cc:281) Loading CARPA model from models/vosk-model-en-us-aspire-0.2/rescore/G.carpa

14:58:24      UID      TGID       TID    %usr %system  %guest   %wait    %CPU   CPU  Command
14:58:25     1000    119364         -   89,00   11,00    0,00    0,00  100,00     0  node
14:58:25     1000         -    119364   89,00   12,00    0,00    0,00  101,00     0  |__node
14:58:25     1000         -    119365    0,00    0,00    0,00    0,00    0,00     0  |__node
14:58:25     1000         -    119366    0,00    0,00    0,00    0,00    0,00     6  |__node
14:58:25     1000         -    119367    0,00    0,00    0,00    0,00    0,00     4  |__node
14:58:25     1000         -    119368    0,00    0,00    0,00    0,00    0,00     0  |__node
14:58:25     1000         -    119369    0,00    0,00    0,00    0,00    0,00     1  |__node
14:58:25     1000         -    119370    0,00    0,00    0,00    0,00    0,00     0  |__node
14:58:25     1000         -    119371    0,00    0,00    0,00    0,00    0,00     0  |__node
14:58:25     1000         -    119372    0,00    0,00    0,00    0,00    0,00     1  |__node
14:58:25     1000         -    119373    0,00    0,00    0,00    0,00    0,00     6  |__node
14:58:25     1000         -    119374    0,00    0,00    0,00    0,00    0,00     0  |__node

init elapsed       : 2118ms
transcript elapsed : 421ms

{
  result: [
    { conf: 0.980891, end: 1.02, start: 0.33, word: 'experience' },
    { conf: 1, end: 1.349903, start: 1.02, word: 'proves' },
    { conf: 0.996779, end: 1.71, start: 1.35, word: 'this' }
  ],
  text: 'experience proves this'
}



Average:      UID      TGID       TID    %usr %system  %guest   %wait    %CPU   CPU  Command
Average:     1000    119364         -   75,00   48,00    0,00    0,00  123,00     -  node
Average:     1000         -    119364   53,50   44,00    0,00    0,00   97,50     -  |__node
Average:     1000         -    119365    0,00    0,00    0,00    0,00    0,00     -  |__node
Average:     1000         -    119366    1,50    0,00    0,00    0,00    1,50     -  |__node
Average:     1000         -    119367    1,50    0,00    0,00    0,00    1,50     -  |__node
Average:     1000         -    119368    1,50    0,00    0,00    0,00    1,50     -  |__node
Average:     1000         -    119369    1,50    0,00    0,00    0,00    1,50     -  |__node
Average:     1000         -    119370    0,00    0,00    0,00    0,00    0,00     -  |__node
Average:     1000         -    119371    0,00    0,00    0,00    0,00    0,00     -  |__node
Average:     1000         -    119372    0,00    0,00    0,00    0,00    0,00     -  |__node
Average:     1000         -    119373    0,00    0,00    0,00    0,00    0,00     -  |__node
Average:     1000         -    119374    0,00    0,00    0,00    0,00    0,00     -  |__node

Unfortunately pidstat allows a poll, not less than every second. Anyway I see the process allocates a variable number of CPUs (from 2 to 7) and in percentage I see a medium value of 100%-123% CPU usage.

Is that mean that when I transcript I get a spike of at list 100% of a core?

I'm asking to understand how to manage a suitable server architecture in nodejs, to allow multiple concurrent requests. My final question is if/when I have to manage nodejs thread workers.

Any suggestion welcome
Thanks
Giorgio

@nshmyrev
Copy link
Collaborator

It use multi cores if available, right?

No, single recognizer uses single core.

I'm asking to understand how to manage a suitable server architecture in nodejs, to allow multiple concurrent requests. My final question is if/when I have to manage nodejs thread workers.

You can check python server implementation. If you have multiple requests you need to create recognizer per request and run each recognizer in own thread or in a shared thread pool.

@solyarisoftware
Copy link
Author

solyarisoftware commented Apr 19, 2021

Thanks @nshmyrev
OK. I'll try to use worker threads to manage a suitable server implementation.
Possibly I'll share the solution as opensource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants