-
Notifications
You must be signed in to change notification settings - Fork 164
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
Archipelagos and the mp_island namespace #106
Comments
This is due to the behaviour of the serialization library we are using (dill). There's a few possible fixes:
class toy_problem:
import numpy as _np
def fitness(self, x):
return [type(self)._np.sum(type(self)._np.sin((x-.2)**2))]
def get_bounds(self):
return (type(self)._np.array([-1] * 3), type(self)._np.array([1] * 3))
import dill
dill.settings['recurse'] = True
import numpy as np
class toy_problem:
... |
Oh thanks, I had been thinking it was an issue with multiprocessing itself. Is this a significant enough issue that I could try to work on a quick documentation update, perhaps under Python Tutorials/Use of the class archipelago? |
It would be good to have a section in the documentation illustrating these types of pitfalls, so feel free to go ahead if you like :) For context, we decided to go with an external serialization library (dill) because, contrary to the standard pickle module, it allows also to serialize classes/functions/etc. defined interactively (note that pagmo also supports standard pickling, it just uses dill instead of pickle when it needs to distribute data to external processes). A library similar to dill is cloudpickle, and we could consider eventually adding support for more serialization protocols if the need arises. For the moment, though, we need more experience before taking a decision like this. |
I'm back with a similar issue already!
dies with
in worker->_evolve_func->estimate_gradient |
Issue confirmed on my system. |
here is the full stack
|
The error is somehow linked to the use of:
as it disappears trying for example |
It is connected to the use of the lambda function in the estimate_gradient call. For some reason, the recurse option of dill causes this issue. If you don't use |
@mishpat we have released version 2.3 which includes the change to cloudpickle. Packages should be up in a few hours. Let us know if it works for you. |
Everything seems to work great now, thanks! |
Hi,
I'm attempting to parallelize some maximization problems I'm working on with pygmo, and I'm running into a bit of an issue. I'm on Win64, Python 3.6.1, Pygmo 2.2. The simplest example I can get to fail that replicated my problem is below.
This fails at wait_check() with the message
Apparently when mp_island creates a pool object, the imports from
__main__
never get imported by the children, not entirely sure why. I can fix this by either 1. not using numpy, or 2. changing fitness tobut obviously this is not a long-term solution, and this problem prevents me from even calling other functions in
__main__
as well as importing any outside modules. Any help is appreciated, thanks.The text was updated successfully, but these errors were encountered: