In [15]:
%%px
In [16]:
import numpy as np
In [1]:
import ipyparallel as ipp
Configure mpi
profile first:
In [ ]:
In [2]:
c = ipp.Client(profile='gpu4')
In [3]:
c.ids
Out[3]:
In [4]:
view = c[:]
In [5]:
view.activate()
In [8]:
%px --block
import os
In [11]:
import os
os.environ
Out[11]:
In [22]:
c[:].apply_sync(lambda : "Hello, World")
Interesting might be:
c = Client('/path/to/my/ipcontroller-client.json', sshserver='me@myhub.example.com')
In [9]:
import mpi4py
In [7]:
%%px
In [8]:
%%writefile psum.py
from mpi4py import MPI
import numpy as np
def psum(a):
locsum = np.sum(a)
rcvBuf = np.array(0.0,'d')
MPI.COMM_WORLD.Allreduce([locsum, MPI.DOUBLE],
[rcvBuf, MPI.DOUBLE],
op=MPI.SUM)
return rcvBuf
In [9]:
view = c[:]
In [10]:
view.activate()
In [11]:
view.run('psum.py')
Out[11]:
In [12]:
view.scatter('a',np.arange(16,dtype='float'))
Out[12]:
In [13]:
view['a']
Out[13]:
In [14]:
%px totalsum = psum(a)
Out[14]:
In [15]:
view['totalsum']
Out[15]:
In [ ]:
In [ ]: