-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
elf setting thread limits with side effects to other libraries/tasks. #75
Comments
k-dominik
added a commit
to k-dominik/ilastik
that referenced
this issue
Jul 13, 2023
elf limits threads on import, which has side effects even for the tiktorch process (via env variables). In order to get proper performance out of neural networks on CPU, we unset these variables before starting the process. xref: constantinpape/elf#75
k-dominik
added a commit
to ilastik/ilastik
that referenced
this issue
Jul 13, 2023
elf limits threads on import, which has side effects even for the tiktorch process (via env variables). In order to get proper performance out of neural networks on CPU, we unset these variables before starting the process. xref: constantinpape/elf#75
@k-dominik : the easiest way to check is this: from elf.util import set_numpy_threads
set_numpy_threads(1)
import time
import numpy as np
x = np.random.rand(2048, 2048)
N = 10
ts = []
print("Start")
for _ in range(N):
t0 = time.time()
x @ x
ts.append(time.time() - t0)
print(min(ts)) This takes ca. |
Hi @k-dominik , |
k-dominik
added a commit
to k-dominik/ilastik
that referenced
this issue
Nov 9, 2023
elf limits threads on import, which has side effects even for the tiktorch process (via env variables). In order to get proper performance out of neural networks on CPU, we unset these variables before starting the process. xref: constantinpape/elf#75
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently,
elf
might set various env variables and set the number of threads formkl
by triggering some of the imports.relevant code:
elf/elf/util.py
Lines 206 to 235 in bed5a57
This has side effects, where e.g. in ilastik, those settings will limit the number of threads, even for subprocesses. Using these functions in a script is probably fine (but who knows what users want to do downstream), but especially in our application context, where a user could do something completely different after some workflow involving
elf
, with detrimental effects to the performance (seen in the neural network classification workflow, which would only predict on a single thread).I think it's worth investigating threadpoolctl for scoped limiting of threads for specific functions.
The text was updated successfully, but these errors were encountered: