<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  'http://www.docbook.org/xml/4.4/docbookx.dtd'><article><articleinfo><title>ParallelNotes</title><revhistory><revision><revnumber>5</revnumber><date>2013-03-08 10:28:27</date><authorinitials>localhost</authorinitials><revremark>converted to 1.6 markup</revremark></revision><revision><revnumber>4</revnumber><date>2008-05-16 09:19:18</date><authorinitials>devel03.mrc-cbu.cam.ac.uk</authorinitials></revision><revision><revnumber>3</revnumber><date>2008-05-14 12:16:22</date><authorinitials>devel03.mrc-cbu.cam.ac.uk</authorinitials></revision><revision><revnumber>2</revnumber><date>2008-05-14 12:13:59</date><authorinitials>devel03.mrc-cbu.cam.ac.uk</authorinitials></revision><revision><revnumber>1</revnumber><date>2008-05-14 12:11:55</date><authorinitials>devel03.mrc-cbu.cam.ac.uk</authorinitials></revision></revhistory></articleinfo><section><title>Alex and Matthew playing with python parallel programming</title><para>Ipython1 - <ulink url="http://ipython.scipy.org/moin/IPython1"/> Docs therefore - <ulink url="http://ipython.scipy.org/doc/ipython1/html"/> </para><para>Then we copied the sshx script from the ipython1 distro into /imaging/local/linux/bin </para><section><title>Shell setup</title><para>The engines use the <code>~/.bashrc</code> to initialize environment variables for the shell (this does not happen by default because <code>sh</code> is used, which does not read startup scripts).  The problem being that Alex is set up with the usual default <code>tcsh</code>, which uses <code>~/.cshrc</code>. </para><para>Accordingly, we added these lines to <code>~/bashrc</code>: </para><screen><![CDATA[# FSL stuff - if we are using FSL
export FSLDIR=/imaging/local/linux/bin/fsl-4.0.1
. ${FSLDIR}/etc/fslconf/fsl.sh
export PATH=${FSLDIR}/bin:$PATH
]]><![CDATA[
cbu_img_sys=/imaging/local/linux
# If on linux, set stuff for libraries, and python
if [ "`/bin/uname`" = "Linux" ]; then
    export PATH=${cbu_img_sys}/bin:$PATH
    export LD_LIBRARY_PATH=${cbu_img_sys}/lib
fi]]></screen></section><section><title>Cluster setup</title><para>We made a tiny script to test with: </para><programlisting format="linespecific" language="python" linenumbering="numbered" startinglinenumber="1"><methodname><![CDATA[controller]]></methodname><![CDATA[ = ]]><token><![CDATA[dict]]></token><![CDATA[(]]><methodname><![CDATA[host]]></methodname><![CDATA[=]]><phrase><![CDATA[']]></phrase><phrase><![CDATA[l42]]></phrase><phrase><![CDATA[']]></phrase><![CDATA[,]]>
<![CDATA[                  ]]><methodname><![CDATA[engine_port]]></methodname><![CDATA[=]]><token><![CDATA[None]]></token><![CDATA[, ]]><lineannotation><![CDATA[# default is 10105]]></lineannotation>
<![CDATA[                  ]]><methodname><![CDATA[control_port]]></methodname><![CDATA[=]]><token><![CDATA[None]]></token><![CDATA[,]]>
<![CDATA[                  )]]>

<lineannotation><![CDATA[# keys are hostnames, values are the number of engines on that host]]></lineannotation>
<methodname><![CDATA[engines]]></methodname><![CDATA[ = ]]><token><![CDATA[dict]]></token><![CDATA[(]]><methodname><![CDATA[l31]]></methodname><![CDATA[=2,]]>
<![CDATA[               ]]><methodname><![CDATA[l32]]></methodname><![CDATA[=2,]]>
<![CDATA[               ]]><methodname><![CDATA[l33]]></methodname><![CDATA[=2,]]>
<![CDATA[               ]]><methodname><![CDATA[l34]]></methodname><![CDATA[=2,]]>
<![CDATA[               )]]>
</programlisting><para>Then we ran <code>ipcluster -f small_cluster.py</code> </para><para>and got this: </para><screen><![CDATA[Starting controller:
Starting engines:   
Sarting 2 engines on l34
Sarting 2 engines on l32
Sarting 2 engines on l33
Sarting 2 engines on l31
]]><![CDATA[
Your cluster is up and running.
]]><![CDATA[
For interactive use, you can make a MultiEngineClient with:
]]><![CDATA[
from ipython1.kernel import client
mec = client.MultiEngineClient(('l42',10105))
]]><![CDATA[
You can then cleanly stop the cluster from IPython using:
]]><![CDATA[
mec.kill(controller=True)]]></screen></section></section></article>