Skip to content

Commit

Permalink
Merge pull request #215 from makaveli10/fix/omp-num-threads
Browse files Browse the repository at this point in the history
fix: limit CPU usage for VAD onnxruntime inference session by setting…
  • Loading branch information
makaveli10 committed May 24, 2024
2 parents a968331 + 819ab35 commit c0a947a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ python3 run_server.py -p 9090 \
-trt /home/TensorRT-LLM/examples/whisper/whisper_small \
-m
```

#### Controlling OpenMP Threads
To control the number of threads used by OpenMP, you can set the `OMP_NUM_THREADS` environment variable. This is useful for managing CPU resources and ensuring consistent performance. If not specified, `OMP_NUM_THREADS` is set to `1` by default. You can change this by using the `--omp_num_threads` argument:
```bash
python3 run_server.py --port 9090 \
--backend faster_whisper \
--omp_num_threads 4
```

### Running the Client
- Initializing the client:
Expand Down
10 changes: 9 additions & 1 deletion run_server.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import argparse
from whisper_live.server import TranscriptionServer
import os

if __name__ == "__main__":
parser = argparse.ArgumentParser()
Expand All @@ -21,12 +21,20 @@
parser.add_argument('--trt_multilingual', '-m',
action="store_true",
help='Boolean only for TensorRT model. True if multilingual.')
parser.add_argument('--omp_num_threads', '-omp',
type=int,
default=1,
help="Number of threads to use for OpenMP")
args = parser.parse_args()

if args.backend == "tensorrt":
if args.trt_model_path is None:
raise ValueError("Please Provide a valid tensorrt model path")

if "OMP_NUM_THREADS" not in os.environ:
os.environ["OMP_NUM_THREADS"] = str(args.omp_num_threads)

from whisper_live.server import TranscriptionServer
server = TranscriptionServer()
server.run(
"0.0.0.0",
Expand Down

0 comments on commit c0a947a

Please sign in to comment.