In [15]:
%%px


UsageError: %%px is a cell magic, but the cell body is empty. Did you mean the line magic %px (single %)?

In [16]:
import numpy as np

In [1]:
import ipyparallel as ipp

In [ ]:


In [2]:
c = ipp.Client(profile='gpu4')

In [3]:
c.ids


Out[3]:
[0]

In [4]:
view = c[:]

In [5]:
view.activate()

In [8]:
%px --block
import os


dev-128-149.smcebi.us.edu.pl

In [11]:
import os
os.environ


Out[11]:
environ({'TERM': 'xterm-color', 'SHELL': '/bin/bash', 'CLICOLOR': '1', 'HOME': '/home/users/marcin.kostur', 'PATH': '/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'USER': 'marcin.kostur', 'LANG': 'C', 'GIT_PAGER': 'cat', 'MPLBACKEND': 'module://ipykernel.pylab.backend_inline', 'JPY_PARENT_PID': '32254', 'PAGER': 'cat'})

In [22]:
c[:].apply_sync(lambda : "Hello, World")


---------------------------------------------------------------------------
NoEnginesRegistered                       Traceback (most recent call last)
<ipython-input-22-9537157e2582> in <module>()
----> 1 c[:].apply_sync(lambda : "Hello, World")

/opt/conda/lib/python3.5/site-packages/ipyparallel/client/client.py in __getitem__(self, key)
    998             raise TypeError("key by int/slice/iterable of ints only, not %s"%(type(key)))
    999         else:
-> 1000             return self.direct_view(key)
   1001 
   1002     def __iter__(self):

/opt/conda/lib/python3.5/site-packages/ipyparallel/client/client.py in direct_view(self, targets, **kwargs)
   1506         # allow 'all' to be lazily evaluated at each execution
   1507         if targets != 'all':
-> 1508             targets = self._build_targets(targets)[1]
   1509         if single:
   1510             targets = targets[0]

/opt/conda/lib/python3.5/site-packages/ipyparallel/client/client.py in _build_targets(self, targets)
    563             # flush notification socket if no engines yet, just in case
    564             if not self.ids:
--> 565                 raise error.NoEnginesRegistered("Can't build targets without any engines")
    566 
    567         if targets is None:

NoEnginesRegistered: Can't build targets without any engines

Interesting might be:

c = Client('/path/to/my/ipcontroller-client.json', sshserver='me@myhub.example.com')

In [9]:
import mpi4py

In [7]:
%%px


UsageError: %%px is a cell magic, but the cell body is empty. Did you mean the line magic %px (single %)?

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


Overwriting psum.py

In [9]:
view = c[:]

In [10]:
view.activate()

In [11]:
view.run('psum.py')


Out[11]:
<AsyncResult: execute>

In [12]:
view.scatter('a',np.arange(16,dtype='float'))


Out[12]:
<AsyncResult: scatter>

In [13]:
view['a']


Out[13]:
[array([ 0.,  1.,  2.,  3.,  4.,  5.,  6.,  7.]),
 array([  8.,   9.,  10.,  11.,  12.,  13.,  14.,  15.])]

In [14]:
%px totalsum = psum(a)


Out[14]:
<AsyncResult: execute>

In [15]:
view['totalsum']


Out[15]:
[array(120.0), array(120.0)]

In [ ]:


In [ ]: