Skip to content

How To Set Or Limit The Number of Threads #921

Answered by seanlaw
seanlaw asked this question in Q&A
Discussion options

You must be logged in to vote

Internally, STUMPY uses numba for its parallel computations. Thus, the number of threads can be controlled by calling the numb.set_num_threads function:

import numpy as np
import stumpy
import numba

if __name__ == "__main__":
    T = np.random.rand(10_000)
    m = 50
    numba.set_num_threads(2)  # This will use only 2 threads
    mp = stumpy.stump(T, m)

Note that calling numba.set_num_threads will affect the number of threads used in ALL parallel computations in STUMPY and not only stumpy.stump. See the numba documentation for more information.

Replies: 1 comment

Comment options

seanlaw
Oct 4, 2023
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by seanlaw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant