Skip to content

Commit

Permalink
set cpu threads according to the machine
Browse files Browse the repository at this point in the history
  • Loading branch information
ozancaglayan committed Aug 18, 2024
1 parent d57c5b4 commit 8ad11ae
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions faster_whisper/transcribe.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import itertools
import json
import logging
import multiprocessing
import os
import random
import zlib
Expand Down Expand Up @@ -587,7 +588,7 @@ def __init__(
device: str = "auto",
device_index: Union[int, List[int]] = 0,
compute_type: str = "default",
cpu_threads: int = 16,
cpu_threads: int = multiprocessing.cpu_count() // 2,
num_workers: int = 1,
download_root: Optional[str] = None,
local_files_only: bool = False,
Expand All @@ -610,8 +611,8 @@ def __init__(
when transcribe() is called from multiple Python threads (see also num_workers).
compute_type: Type to use for computation.
See https://opennmt.net/CTranslate2/quantization.html.
cpu_threads: Number of threads to use when running on CPU (4 by default).
A non zero value overrides the OMP_NUM_THREADS environment variable.
cpu_threads: Number of threads to use when running on CPU (number of physical
cores by default). A non zero value overrides the OMP_NUM_THREADS environment variable.
num_workers: When transcribe() is called from multiple Python threads,
having multiple workers enables true parallelism when running the model
(concurrent calls to self.model.generate() will run in parallel).
Expand Down

0 comments on commit 8ad11ae

Please sign in to comment.