<div dir="ltr"><div>Hello,</div><div><br></div><div>I'm trying to figure out the use of the IPython parallel scheme for some of the processing we are doing. In effect, what we have is a bunch of calculations on a vector, and we have tons of these vectors, stored in an (N,11) matrix, where N is typically >10E6. The calculations involve an euclidean distance and a few vector/matix, matrix/vector products (these are typically reasonable matrices, say 200x200 or so). First idea is to approach the problem by splitting the starting (N,11) matrix into (N/s, 11) matrices (s being the number of nodes) and evaluate them in parallel.</div><div><br></div><div><font face="monospace">from IPython.parallel import *</font></div><div><font face="monospace">import numpy as np</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">client = Client(profile="default")</font></div><div><font face="monospace">ids    = client.ids</font></div><div><font face="monospace">nodes  = len(ids)</font></div><div><font face="monospace">view   = client.load_balanced_view()</font></div><div><font face="monospace">dview  = client[:]</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">with dview.sync_imports():</font></div><div><font face="monospace">    import numpy as np</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"><br></font></div><div><font face="monospace">def the_func ( x ):</font></div><div><font face="monospace">    """Does some numerical stuff with a vector `x`"""</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"><br></font></div><div><font face="monospace">@dview.parallel(block=True)</font></div><div><font face="monospace">def run_func ( inputx ):</font></div><div><font face="monospace">    (x,f) = inputx</font></div><div><font face="monospace">    return f(x)</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"><br></font></div><div><font face="monospace">X=np.random.randn(8000000,2)</font></div><div><font face="monospace"># parallel run</font></div><div><font face="monospace">Y = run_func.map ( [(X[(2000000*i):(i+1)*2000000], the_func) for i in xrange(nodes)] )</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"># serial run</font></div><div><font face="monospace">YY = the_func(X)</font></div><div><br></div><div><br></div><div><br></div><div>The above code works OK. htop tells me it's using all cores on my laptop. If I just run the_func(X), it appears to use only one core (htop dixit), and it takes a little bit longer (~10-15%), which maybe is a lot to do with parallel linear algebra inside of the local BLAS version or internal optimisations on scipy's euclidean distance calculations.</div><div><br></div><div>We plan to use this on an IPython cluster connected with SSH, to which I don't yet have access. Are there some obvious guidelines about optimising for this new setup that I need to know? And yes, hoping to get a bigger speed up as we increase the size of our problem and nodes!</div><div><br></div><div>Thanks!</div><div>Jose</div></div>