I am trying to parallelize a function inside a pool using the multiprocessing
module, but I run into the error:
daemonic processes are not allowed to have children
More specifically, I am using emcee
module which makes use of the multiprocessing
module for parallelization, and I would like to parallelize my posterior function as well to speed up the calculations. Is there a way to parallelize a function inside the main Pool
in this case?
Edit (code added):
# defines the log-posterior probability distribution
def logp(p):
mu_imf, mu_h0, sigma_h, b_h = p
logpost = np.zeros(ngal, dtype='longdouble')
for i in range(ngal):
logpost[i] = np.log(quad(lambda m_halo: Integrand(m_halo, i, mu_imf, mu_h0, sigma_h, b_h), 11.9, 15.0107)[0])
return np.sum(logpost)
with Pool() as pool:
sampler = emcee.EnsembleSampler(nwalkers, npars, logp, pool=pool)