Skip to content

Commit

Permalink
Use mp_ctx forkserver on MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
aseyboldt committed Jul 6, 2020
1 parent 8e8bd86 commit 8f14987
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 0 additions & 6 deletions pymc3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions pymc3/parallel_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import pickle
from collections import namedtuple
import traceback
import platform
from pymc3.exceptions import SamplingError

import numpy as np
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8f14987

Please sign in to comment.