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 mpl and multithreading #84

Closed
wants to merge 8 commits into from
10 changes: 9 additions & 1 deletion src/py21cmmc/mcmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
from py21cmfast import yaml
from py21cmfast._utils import ParameterError

# from concurrent.futures import ProcessPoolExecutor
from schwimmbad import MultiPool

from .cosmoHammer import (
CosmoHammerSampler,
HDFStorageUtil,
Expand Down Expand Up @@ -577,9 +580,14 @@ def prior(p):
return sampler, result

else:
# didn't spawn Pools in my case, setting mp_context (either spawn or fork) fixed it
pool = mcmc_options.pop(
"pool",
ProcessPoolExecutor(max_workers=mcmc_options.get("threadCount", 1)),
ProcessPoolExecutor(
max_workers=mcmc_options.get("threadCount", 1),
max_tasks_per_child=1,
mp_context="spawn",
),
)
sampler = sampler_cls(
continue_sampling=continue_sampling,
Expand Down
Loading