Skip to content
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

[FIX] peakfit: limit multiprocessing to 2 processes during fitting to avoid crashes #748

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions doc/widgets/peakfit.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,11 @@ Common uses of these constraints would be:
- Limiting the *center* position to some range of x values
- Setting a minimum *amplitude* to force positive peaks
- Setting a maximum *sigma* to exclude unreasonably wide peaks

Advanced
--------

Unlike the majority of widgets, **Peak Fit** uses multiple processes during fitting to improve
responsiveness and performance. By default this is limited to 2 extra processes, but this can be
overridden by setting the environment variable `QUASAR_N_PROCESSES` to the desired number, or `all`
to use the default value returned by `os.cpu_count()`.
5 changes: 4 additions & 1 deletion orangecontrib/spectroscopy/widgets/owpeakfit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from functools import reduce
import concurrent.futures
import multiprocessing
import os

from lmfit import Parameters, Model
from lmfit.model import ModelResult
Expand Down Expand Up @@ -36,7 +37,9 @@
best_fit_results, pool_initializer, pool_fit, pool_fit2

# number of processes used for computation
N_PROCESSES = None
# Use 2 or less unless overridden by QUASAR_N_PROCESSES
env_proc = os.getenv('QUASAR_N_PROCESSES')
N_PROCESSES = None if env_proc == "all" else int(env_proc) if env_proc else min(2, multiprocessing.cpu_count())


def fit_results_table(output, model_result, orig_data):
Expand Down
Loading