Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How To Set Or Limit The Number of Threads #921

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

By default, STUMPY uses all of the local threads when computing the matrix profile. Instead of using all threads, how can we limit or set the number of threads to be used?

Note: This question is concerning only the local threads on a single (1) machine/server and is different from "distributed" computation across multiple machines/servers!

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

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.

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

AltStyle によって変換されたページ (->オリジナル) /