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

Replace multiprocessing with multiprocess #480

Closed
scimax opened this issue Sep 8, 2021 · 4 comments
Closed

Replace multiprocessing with multiprocess #480

scimax opened this issue Sep 8, 2021 · 4 comments
Labels
stale Not much activity here

Comments

@scimax
Copy link

scimax commented Sep 8, 2021

Hello everyone,
I just started to use pyswarms, thank you a lot for the nice package. During exploring the features I came across a minor issue.

Is your feature request related to a problem? Please describe.
I'm mainly using jupyter notebooks (conda python 3.8, Windows 10), but when running the optimizer with multiple processes, i.e.

cost, pos = optimizer.optimize(rosenbrock_with_args, 1000, n_processes=2, a=1, b=100, c=0)

the jupyter notebook is busy, but does nothing and the kernel cann't be interrupted. An error is thrown in the console from which the notebook is started, AttributeError: Can't get attribute 'f' on <module '__main__' (built-in)>. As it turns out, this is a known problem of multiprocessing, and it is not related to pyswarms by itself.

Describe the solution you'd like
Run parallelized optimization from jupyter notebooks. According to the stack exchange post, one solution is to replace multiprocessing with the fork multiprocess. I've tested it with the example from the multiprocessing documentation and it works out of the box. I see no reason why it should not work with pyswarms

Additional context
Just replacing multiprocessing with multiprocess should not be too difficult and, if there is interest, I would provide a PR. What do you think?

Thanks!

@stale
Copy link

stale bot commented Jan 8, 2022

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale Not much activity here label Jan 8, 2022
@chrisotoro
Copy link

I'm interested in this. Is there a quick way to implement it?

@stale stale bot removed the stale Not much activity here label Jan 21, 2022
@scimax
Copy link
Author

scimax commented Jan 23, 2022

@chrisotoro sorry, I'm pretty busy right now and had no time to look at it so far. But as far as I remember I did exactly what I mentioned above. But if you give me a day, I can look it up.

@stale
Copy link

stale bot commented Apr 16, 2022

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale Not much activity here label Apr 16, 2022
@stale stale bot closed this as completed Apr 27, 2022
scimax added a commit to scimax/pyswarms that referenced this issue Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Not much activity here
Projects
None yet
Development

No branches or pull requests

2 participants