From 5d408c0bb679f916f8bf600528293752d0007f76 Mon Sep 17 00:00:00 2001 From: Adrian Seyboldt Date: Mon, 6 Jul 2020 17:51:10 +0200 Subject: [PATCH] Use mp_ctx forkserver on MacOS --- pymc3/__init__.py | 6 ------ pymc3/parallel_sampling.py | 4 ++++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pymc3/__init__.py b/pymc3/__init__.py index 21ec7f3a591..ad47bbbfe28 100644 --- a/pymc3/__init__.py +++ b/pymc3/__init__.py @@ -27,12 +27,6 @@ handler = logging.StreamHandler() _log.addHandler(handler) -# Set start method to forkserver for MacOS to enable multiprocessing -# Closes issue https://github.com/pymc-devs/pymc3/issues/3849 -sys = platform.system() -if sys == "Darwin": - new_context = mp.get_context("forkserver") - def __set_compiler_flags(): # Workarounds for Theano compiler problems on various platforms diff --git a/pymc3/parallel_sampling.py b/pymc3/parallel_sampling.py index 84f2f88f79e..fb4b464b01c 100644 --- a/pymc3/parallel_sampling.py +++ b/pymc3/parallel_sampling.py @@ -20,6 +20,7 @@ import pickle from collections import namedtuple import traceback +import platform from pymc3.exceptions import SamplingError import numpy as np @@ -420,6 +421,9 @@ def __init__( raise ValueError("Number of seeds and start_points must be %s." % chains) if mp_ctx is None or isinstance(mp_ctx, str): + # Closes issue https://github.com/pymc-devs/pymc3/issues/3849 + if platform.system() == 'Darwin': + mp_ctx = "forkserver" mp_ctx = multiprocessing.get_context(mp_ctx) step_method_pickled = None