optunity
optunity copied to clipboard
Is there any examples on using optunity.parallel.pmap?
I didn' t found any example on it. Can you provide some example?
This function provides equivalent functionality as Python's map
, but uses a threadpool to parallelize evaluations. The usual place to use it in Optunity is within optimize
, maximize
or minimize
, e.g.
import optunity
f = lambda x, y: x + y
pars, _, _ = optunity.minimize(f, x=[0, 1], y=[0, 1], num_evals=1000, pmap=optunity.pmap)
Note that optunity.pmap
== optunity.parallel.pmap
.
By default, optunity.parallel.pmap
will use the number of cores as the size of the threadpool. If you prefer to set the amount manually, you can use optunity.parallel.create_pmap(threadpool_size)
, e.g.:
import optunity
f = lambda x, y: x + y
pmap4 = optunity.parallel.create_pmap(4)
pars, _, _ = optunity.minimize(f, x=[0, 1], y=[0, 1], num_evals=1000, pmap=pmap4)
I just noticed that optunity.parallel.create_pmap
isn't properly documented yet, I'll do that ASAP.
Thanks. optunity.parallel.create_pmap
is what I want.
This was returned by the example shown above in Python 2.7.10:
Traceback (most recent call last):
File "
Traceback (most recent call last): File "
", line 1, in File "D:\Python27\lib\multiprocessing\forking.py", line 381, in main self = load(from_parent) File "D:\Python27\lib\pickle.py", line 1384, in load return Unpickler(file).load() File "D:\Python27\lib\pickle.py", line 864, in load dispatchkey File "D:\Python27\lib\pickle.py", line 886, in load_eof raise EOFError EOFError
Could you please advice what need to be done to run optunity parallel?
Yes. Even I am getting a similar kind of error. I tried to run it in python console. Still getting the same error.
This works well in Ubuntu. However, if I run the above code, then without using 'pmap' gives faster output, compared to with 'pmap'.