question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MCMC sampler does not work with MPI=False and threadCount > 1

See original GitHub issue

The schwimmbad.choose_pool method, when mpi=False and threadCount > 1 returns a MultiPool object that has no is_master attribute, hence the following error :


  File "/Users/aymericg/Documents/EPFL/PhD_LASTRO/Code/Forked/lenstronomy_forked/lenstronomy/Workflow/fitting_sequence.py", line 94, in fit_sequence
    mcmc_output = self.mcmc(**kwargs)
  File "/Users/aymericg/Documents/EPFL/PhD_LASTRO/Code/Forked/lenstronomy_forked/lenstronomy/Workflow/fitting_sequence.py", line 230, in mcmc
    threadCount=threadCount, progress=progress)
  File "/Users/aymericg/Documents/EPFL/PhD_LASTRO/Code/Forked/lenstronomy_forked/lenstronomy/Sampling/sampler.py", line 149, in mcmc_emcee
    if pool.is_master():
AttributeError: 'MultiPool' object has no attribute 'is_master'

In addition, I see that the new schwimmbad way of dealing with pools calls the multiprocessing module instead of the multiprocess, as it was done before in lenstronomy, and which is more robust because of pickling issues in multiprocessing. @ajshajib , could you please look into that since you introduced this change ?

I did not test for the PSO, but it’s likely to give the same result.

In the meantime, I will temporarily make my own fork of schwimmbad to fix that, but it’s not viable to link lenstronomy to this fork.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:20

github_iconTop GitHub Comments

1reaction
aymgalcommented, Mar 16, 2020

Ok thanks @sibirrer , I’ll prepare the changes

1reaction
sibirrercommented, Mar 16, 2020

Ok no problem, but what’s your preference @sibirrer ? I propose a change to schwimmbad master branch, or I write a “hack” in lenstronomy ?

up to you @aymgal. It would be great if we can minimize outside dependence on ‘unstable’ development. If you implement it in lenstronomy, I would not call it a ‘hack’ if you well document the in- and outputs, its current purpose and reason for doing it there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Source code for lenstronomy.Sampling.sampler
[docs]class Sampler(object): """ class which executes the different sampling methods Available are: MCMC with emcee a Particle Swarm Optimizer.
Read more >
MCMC sampling does not work when execute - Modeling
Hi everyone, I currently have trouble executing the below stan model, but I could not detect why it keeps giving me this error...
Read more >
MCMC Settings
The sampling is done by the software JAGS (“Just Another Gibbs Sampler”), which performs Gibbs sampling. JointAI pre-processes the data to get ...
Read more >
MCMC sampling for dummies
Setting up the problem¶. First, lets import our modules. In [1]:.
Read more >
MCMC convergence - bayesian - Cross Validated
Sometimes, the sampler you are using might be not the best choice. For example, if your problem deals with continuous variables with a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found