Skip to content

Commit

Permalink
Merge pull request #57 from reginabarzilaygroup/v1.6.1_dev
Browse files Browse the repository at this point in the history
Set default number of threads to min(8, cpu count)
  • Loading branch information
jsilter authored Oct 30, 2024
2 parents 479de0a + 88ad559 commit 1e358f8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sybil/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ def _torch_set_num_threads(threads) -> int:
if threads < 0:
return torch.get_num_threads()
if threads is None or threads == 0:
threads = os.cpu_count()
# I've never seen a benefit to going higher than 8 and sometimes there is a big slowdown
threads = min(8, os.cpu_count())

torch.set_num_threads(threads)
return torch.get_num_threads()
Expand Down Expand Up @@ -315,7 +316,7 @@ def predict(
return_attentions : bool
If True, returns attention scores for each serie. See README for details.
threads : int
Number of CPU threads to use for PyTorch inference. Default is 0 (use all available cores).
Number of CPU threads to use for PyTorch inference.
Returns
-------
Expand Down

0 comments on commit 1e358f8

Please sign in to comment.