SlideShare uma empresa Scribd logo
1 de 16
Baixar para ler offline
Parallel Processing with IPython



          January 22, 2010
Enthought Python Distribution (EPD)

 MORE THAN SIXTY INTEGRATED PACKAGES

  • Python 2.6                     • Repository access
  • Science (NumPy, SciPy, etc.)   • Data Storage (HDF, NetCDF, etc.)
  • Plotting (Chaco, Matplotlib)   • Networking (twisted)
  • Visualization (VTK, Mayavi)    • User Interface (wxPython, Traits UI)
  • Multi-language Integration     • Enthought Tool Suite
    (SWIG,Pyrex, f2py, weave)        (Application Development Tools)
Enthought Training Courses




                 Python Basics, NumPy,
                 SciPy, Matplotlib, Chaco,
                 Traits, TraitsUI, …
PyCon


    http://us.pycon.org/2010/tutorials/

        Introduction to Traits
        Introduction to Enthought Tool Suite

        Fantastic deal (normally $700 at PyCon
          get the same material for $275)




                                                 Corran Webster
Upcoming Training Classes
  March 1 – 5, 2009
       Python for Scientists and Engineers
       Austin, Texas, USA

  March 1 – 5, 2009
       Python for Quants
       London, UK




                       http://www.enthought.com/training/
Parallel Processing
        with
      IPython



                      6
IPython.kernel

 • IPython's interactive kernel provides a
   simple (but powerful) interface for task-
   based parallel programming.
 • Allows fast development and tuning of
   task-parallel algorithm to better utilize
   resources.



                                               7
Getting started --- local cluster
UNIX and OSX (and now WINDOWS)                               manually WINDOWS
# run ipcluster to start-up a                            # run ipcontroller and then
# controller and a set of engines                        # ipengine for each desired engine
$ ipcluster local –n 4                                   >   start   /B   C:Python25Scriptsipcontroller.exe
Your cluster is up and running.                          >   start   /B   C:Python25Scriptsipengine.exe
                                                         >   start   /B   C:Python25Scriptsipengine.exe
...                                                      >   start   /B   C:Python25Scriptsipengine.exe
                                                          ...
You can then cleanly stop the cluster from IPython using: 2009-02-11 23:58:26-0600 [-] Log opened.
                                                          2009-02-11 23:58:28-0600 [-] Using furl file: C:Documents
mec.kill(controller=True)                                 and Settingsdemo_ip
                                                          ythonsecurityipcontroller-engine.furl
You can also hit Ctrl-C to stop it, or use from the cmd   2009-02-11 23:58:28-0600 [-] registered engine with id: 3
line:                                                     2009-02-11 23:58:28-0600 [-] distributing Tasks
                                                          2009-02-11 23:58:28-0600 [Negotiation,client] engine
kill -INT 20465                                           registration succeeded, got
                                                           id: 3




                                                             Creates several key-files in
Creates several key-files in                                  %HOME%_ipythonsecurity :
 ~/.ipython/security :
                                                                ipcontroller-engine.furl
      ipcontroller-engine.furl                                  ipcontroller-mec.furl
      ipcontroller-mec.furl                                     ipcontroller-tc.furl
      ipcontroller-tc.furl

                                                                                                      8
Getting started -- distributed
 • Run ipcontroller on a host and create .furl files
    • Creates separate .furl files to be used by the different connections (engine,
      multiengine client, task client).
    • Places .furl files by default in ~/.ipython/security (UNIX or Mac OSX) or
      %HOME%_ipythonsecurity (Windows).
    • Takes --<connection>-furl-file=FILENAME options where <connection> is
      engine, multiengine, or task to place the .furl files somewhere else.

 • Ensure the ipcontroller-engine.furl file is available to each host that
   will run an engine and run ipengine on these hosts.
    • Either place it in the default security directory
    • Use the –furl-file=FILENAME option to ipengine

 • Ensure the multiengine (task) .furl file is available to each host that
   will run a multiengine (task) client.
    • Either place it in the default security directory
    • Pass the FILENAME as the first argument to the constructor
                                                                                      9
Initialize client
 >>> from IPython.kernel import client
MULTIENGINECLIENT                        TASKCLIENT
# * allows fine-grained control         # * does not expose individual
# * each engine has an id number        #    engines
# * more intuitive for beginners        # * presents a load-balanced,
# optional argument can be              #    fault-tolerant queue
# location of mec furl-file             # optional argument can be
# created by the controller             # location of tc furl-file
>>> mec = client.MultiEngineClient()    # created by the controller
>>> mec.get_ids()                       >>> tc = client.TaskClient()
[0 1 2 3]


mec.map        -- parallel map          tc.map      –- parallel map
mec.parallel   –- parallel function     tc.parallel –- function decorator
mec.execute    -- execute in parallel   tc.run      -- run Tasks
mec.push       -- push data             tc.get_task_result – get result
mec.pull       -- pull data
mec.scatter    -- spread out            client.MapTask –- function-like
mec.gather     -- collect back          client.StringTask –- code-string
mec.kill       -- kill engines
               and controller
                                                                    10
MultiEngineClient
SCALAR FUNCTION  PARALLEL VECTORIZED FUNCTION

# Using map
>>> def func(x):
...     return x**2.5 * (3*x – 2)
# standard map
>>> result = map(func, range(32))
# mec.map
>>> parallel_result = mec.map(func, range(32))

# mec.parallel
>>> pfunc = mec.parallel()(func)

                                     or using decorators
                         @mec.parallel
                         def pfunc(x):
                             return x**2.5 * (3*x – 2)


>>> parallel_result2 = pfunc(range(32))
                                                           11
TaskClient – Load Balancing
SCALAR FUNCTION  PARALLEL VECTORIZED FUNCTION

# Using map
>>> def func(x):
...     return x**2.5 * (3*x – 2)
# standard map
>>> result = map(func, range(32))
# mec.map
>>> parallel_result = tc.map(func, range(32))

# mec.parallel
>>> pfunc = tc.parallel()(func)

                                     or using decorators
                         @tc.parallel
                         def pfunc(x):
                             return x**2.5 * (3*x – 2)


>>> parallel_result2 = pfunc(range(32))
                                                           12
MultiEngineClient
EXECUTE CODESTRING IN PARALLEL

>>> from enthought.blocks.api import func2str
# decorator that turns python-code into a string
>>> @func2str
... def code():
...     import numpy as np
...     a = np.random.randn(N,N)
...     eigs, vals = np.linalg.eig(a)
...     maxeig = max(abs(eigs))
>>> mec['N'] = 100
>>> result = mec.execute(code)
>>> print mec['maxeig']
[10.471428625885835, 10.322386155553213, 10.237638983818622, 10.614715948426941]




                                                                               13
TaskClient – Load Balancing Queue
EXECUTE CODESTRING IN PARALLEL

>>> from enthought.blocks.api import func2str
# decorator that turns python-code into a string
>>> @func2str
... def code():
...     import numpy as np
...     a = np.random.randn(N,N)
...     eigs, vals = np.linalg.eig(a)
...     maxeig = max(abs(eigs))
>>> task = client.StringTask(str(code), push={'N':100},
                             pull='maxeig')
>>> ids = [tc.run(task) for i in range(4)]
>>> res = [tc.get_task_result(id) for id in ids]
>>> print [x['maxeig'] for x in res]
[10.439989436983467, 10.250842410862729, 10.040835983392991, 10.603885977189803]




                                                                               14
Parallel FFT On Memory Mapped File




                Time
 Processors               Speed Up
              (seconds)
     1          11.75       1.0
     2           6.06       1.9
     4           3.36       3.5

     8           2.50       4.7
EPD
http://www.enthought.com/products/epd.php


Webinars
http://www.enthought.com/training/webinars.php


Enthought Training:
http://www.enthought.com/training/

Mais conteúdo relacionado

Mais procurados

Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary dataKernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Anne Nicolas
 
ikh331-06-distributed-programming
ikh331-06-distributed-programmingikh331-06-distributed-programming
ikh331-06-distributed-programming
Anung Ariwibowo
 
How to recover malare assembly codes
How to recover malare assembly codesHow to recover malare assembly codes
How to recover malare assembly codes
FACE
 
Android audio system(audioflinger)
Android audio system(audioflinger)Android audio system(audioflinger)
Android audio system(audioflinger)
fefe7270
 

Mais procurados (20)

Using Entity Command Buffers – Unite Copenhagen 2019
Using Entity Command Buffers – Unite Copenhagen 2019Using Entity Command Buffers – Unite Copenhagen 2019
Using Entity Command Buffers – Unite Copenhagen 2019
 
Fun with Network Interfaces
Fun with Network InterfacesFun with Network Interfaces
Fun with Network Interfaces
 
Cotap Tech Talks: Keith Lazuka, Digital Communication using Sound and Swift
Cotap Tech Talks: Keith Lazuka, Digital Communication using Sound and SwiftCotap Tech Talks: Keith Lazuka, Digital Communication using Sound and Swift
Cotap Tech Talks: Keith Lazuka, Digital Communication using Sound and Swift
 
Understanding greenlet
Understanding greenletUnderstanding greenlet
Understanding greenlet
 
Decompressed vmlinux: linux kernel initialization from page table configurati...
Decompressed vmlinux: linux kernel initialization from page table configurati...Decompressed vmlinux: linux kernel initialization from page table configurati...
Decompressed vmlinux: linux kernel initialization from page table configurati...
 
Contiki os timer tutorial
Contiki os timer tutorialContiki os timer tutorial
Contiki os timer tutorial
 
Process Address Space: The way to create virtual address (page table) of user...
Process Address Space: The way to create virtual address (page table) of user...Process Address Space: The way to create virtual address (page table) of user...
Process Address Space: The way to create virtual address (page table) of user...
 
Specializing the Data Path - Hooking into the Linux Network Stack
Specializing the Data Path - Hooking into the Linux Network StackSpecializing the Data Path - Hooking into the Linux Network Stack
Specializing the Data Path - Hooking into the Linux Network Stack
 
Новый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоныНовый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоны
 
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary dataKernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
 
Python import mechanism
Python import mechanismPython import mechanism
Python import mechanism
 
ikh331-06-distributed-programming
ikh331-06-distributed-programmingikh331-06-distributed-programming
ikh331-06-distributed-programming
 
Configuration management I - Ansible + Packer
Configuration management I - Ansible + PackerConfiguration management I - Ansible + Packer
Configuration management I - Ansible + Packer
 
How to recover malare assembly codes
How to recover malare assembly codesHow to recover malare assembly codes
How to recover malare assembly codes
 
Qemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System EmulationQemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System Emulation
 
Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage Go
 
Android audio system(audioflinger)
Android audio system(audioflinger)Android audio system(audioflinger)
Android audio system(audioflinger)
 
Microkernel Development
Microkernel DevelopmentMicrokernel Development
Microkernel Development
 
Go concurrency
Go concurrencyGo concurrency
Go concurrency
 
The async/await concurrency pattern in Golang
The async/await concurrency pattern in GolangThe async/await concurrency pattern in Golang
The async/await concurrency pattern in Golang
 

Destaque

Parallel batch processing with spring batch slideshare
Parallel batch processing with spring batch   slideshareParallel batch processing with spring batch   slideshare
Parallel batch processing with spring batch slideshare
Morten Andersen-Gott
 
Information processing approach
Information processing approachInformation processing approach
Information processing approach
aj9ajeet
 

Destaque (14)

Using GPUs for parallel processing
Using GPUs for parallel processingUsing GPUs for parallel processing
Using GPUs for parallel processing
 
Geoff Rothman Presentation on Parallel Processing
Geoff Rothman Presentation on Parallel ProcessingGeoff Rothman Presentation on Parallel Processing
Geoff Rothman Presentation on Parallel Processing
 
Parallel Processing for Digital Image Enhancement
Parallel Processing for Digital Image EnhancementParallel Processing for Digital Image Enhancement
Parallel Processing for Digital Image Enhancement
 
Introduction to Parallel Processing Algorithms in Shared Nothing Databases
Introduction to Parallel Processing Algorithms in Shared Nothing DatabasesIntroduction to Parallel Processing Algorithms in Shared Nothing Databases
Introduction to Parallel Processing Algorithms in Shared Nothing Databases
 
Massively Parallel Processing with Procedural Python - Pivotal HAWQ
Massively Parallel Processing with Procedural Python - Pivotal HAWQMassively Parallel Processing with Procedural Python - Pivotal HAWQ
Massively Parallel Processing with Procedural Python - Pivotal HAWQ
 
QGIS plugin for parallel processing in terrain analysis
QGIS plugin for parallel processing in terrain analysisQGIS plugin for parallel processing in terrain analysis
QGIS plugin for parallel processing in terrain analysis
 
Parallel processing & Multi level logic
Parallel processing & Multi level logicParallel processing & Multi level logic
Parallel processing & Multi level logic
 
ReStream: Accelerating Backtesting and Stream Replay with Serial-Equivalent P...
ReStream: Accelerating Backtesting and Stream Replay with Serial-Equivalent P...ReStream: Accelerating Backtesting and Stream Replay with Serial-Equivalent P...
ReStream: Accelerating Backtesting and Stream Replay with Serial-Equivalent P...
 
Parallel batch processing with spring batch slideshare
Parallel batch processing with spring batch   slideshareParallel batch processing with spring batch   slideshare
Parallel batch processing with spring batch slideshare
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
 
Scaling up with hadoop and banyan at ITRIX-2015, College of Engineering, Guindy
Scaling up with hadoop and banyan at ITRIX-2015, College of Engineering, GuindyScaling up with hadoop and banyan at ITRIX-2015, College of Engineering, Guindy
Scaling up with hadoop and banyan at ITRIX-2015, College of Engineering, Guindy
 
Information processing approach
Information processing approachInformation processing approach
Information processing approach
 
Massively Parallel Processing with Procedural Python (PyData London 2014)
Massively Parallel Processing with Procedural Python (PyData London 2014)Massively Parallel Processing with Procedural Python (PyData London 2014)
Massively Parallel Processing with Procedural Python (PyData London 2014)
 
Introduction to parallel computing using CUDA
Introduction to parallel computing using CUDAIntroduction to parallel computing using CUDA
Introduction to parallel computing using CUDA
 

Semelhante a Parallel Processing with IPython

Exploiting Llinux Environment
Exploiting Llinux EnvironmentExploiting Llinux Environment
Exploiting Llinux Environment
Enrico Scapin
 
Monitoring CPU Utilization on LINUX (Shell Script Project)
Monitoring CPU Utilization on LINUX (Shell Script Project)Monitoring CPU Utilization on LINUX (Shell Script Project)
Monitoring CPU Utilization on LINUX (Shell Script Project)
Dmitry Ponomarenko
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time Optimization
Kan-Ru Chen
 
Pascal script maxbox_ekon_14_2
Pascal script maxbox_ekon_14_2Pascal script maxbox_ekon_14_2
Pascal script maxbox_ekon_14_2
Max Kleiner
 

Semelhante a Parallel Processing with IPython (20)

Intermediate Intel® Distribution of OpenVINO™ toolkit for Computer Vision Ap...
 Intermediate Intel® Distribution of OpenVINO™ toolkit for Computer Vision Ap... Intermediate Intel® Distribution of OpenVINO™ toolkit for Computer Vision Ap...
Intermediate Intel® Distribution of OpenVINO™ toolkit for Computer Vision Ap...
 
LSA2 - 02 Namespaces
LSA2 - 02  NamespacesLSA2 - 02  Namespaces
LSA2 - 02 Namespaces
 
Exploiting Llinux Environment
Exploiting Llinux EnvironmentExploiting Llinux Environment
Exploiting Llinux Environment
 
Monitoring CPU Utilization on LINUX (Shell Script Project)
Monitoring CPU Utilization on LINUX (Shell Script Project)Monitoring CPU Utilization on LINUX (Shell Script Project)
Monitoring CPU Utilization on LINUX (Shell Script Project)
 
Automating with NX-OS: Let's Get Started!
Automating with NX-OS: Let's Get Started!Automating with NX-OS: Let's Get Started!
Automating with NX-OS: Let's Get Started!
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time Optimization
 
Python Network Programming – Course Applications Guide
Python Network Programming – Course Applications GuidePython Network Programming – Course Applications Guide
Python Network Programming – Course Applications Guide
 
Ansible101
Ansible101Ansible101
Ansible101
 
Pascal script maxbox_ekon_14_2
Pascal script maxbox_ekon_14_2Pascal script maxbox_ekon_14_2
Pascal script maxbox_ekon_14_2
 
Vagrant, Ansible, and OpenStack on your laptop
Vagrant, Ansible, and OpenStack on your laptopVagrant, Ansible, and OpenStack on your laptop
Vagrant, Ansible, and OpenStack on your laptop
 
Intermediate Intel® Distribution of OpenVINO™ toolkit for Computer Vision Ap...
 Intermediate Intel® Distribution of OpenVINO™ toolkit for Computer Vision Ap... Intermediate Intel® Distribution of OpenVINO™ toolkit for Computer Vision Ap...
Intermediate Intel® Distribution of OpenVINO™ toolkit for Computer Vision Ap...
 
Automation with Ansible and Containers
Automation with Ansible and ContainersAutomation with Ansible and Containers
Automation with Ansible and Containers
 
Beyond Golden Containers: Complementing Docker with Puppet
Beyond Golden Containers: Complementing Docker with PuppetBeyond Golden Containers: Complementing Docker with Puppet
Beyond Golden Containers: Complementing Docker with Puppet
 
Python Programming Essentials - M35 - Iterators & Generators
Python Programming Essentials - M35 - Iterators & GeneratorsPython Programming Essentials - M35 - Iterators & Generators
Python Programming Essentials - M35 - Iterators & Generators
 
Introduction to Linux Kernel Development
Introduction to Linux Kernel DevelopmentIntroduction to Linux Kernel Development
Introduction to Linux Kernel Development
 
Mininet Basics
Mininet BasicsMininet Basics
Mininet Basics
 
BKK16-211 Internet of Tiny Linux (io tl)- Status and Progress
BKK16-211 Internet of Tiny Linux (io tl)- Status and ProgressBKK16-211 Internet of Tiny Linux (io tl)- Status and Progress
BKK16-211 Internet of Tiny Linux (io tl)- Status and Progress
 
PyCon Estonia 2019
PyCon Estonia 2019PyCon Estonia 2019
PyCon Estonia 2019
 
Python Hashlib & A True Story of One Bug
Python Hashlib & A True Story of One BugPython Hashlib & A True Story of One Bug
Python Hashlib & A True Story of One Bug
 
Activity 5
Activity 5Activity 5
Activity 5
 

Mais de Enthought, Inc.

Mais de Enthought, Inc. (14)

Numpy Talk at SIAM
Numpy Talk at SIAMNumpy Talk at SIAM
Numpy Talk at SIAM
 
Talk at NYC Python Meetup Group
Talk at NYC Python Meetup GroupTalk at NYC Python Meetup Group
Talk at NYC Python Meetup Group
 
Scientific Applications with Python
Scientific Applications with PythonScientific Applications with Python
Scientific Applications with Python
 
SciPy 2010 Review
SciPy 2010 ReviewSciPy 2010 Review
SciPy 2010 Review
 
Scientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
Scientific Computing with Python Webinar March 19: 3D Visualization with MayaviScientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
Scientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
 
Chaco Step-by-Step
Chaco Step-by-StepChaco Step-by-Step
Chaco Step-by-Step
 
NumPy/SciPy Statistics
NumPy/SciPy StatisticsNumPy/SciPy Statistics
NumPy/SciPy Statistics
 
February EPD Webinar: How do I...use PiCloud for cloud computing?
February EPD Webinar: How do I...use PiCloud for cloud computing?February EPD Webinar: How do I...use PiCloud for cloud computing?
February EPD Webinar: How do I...use PiCloud for cloud computing?
 
SciPy India 2009
SciPy India 2009SciPy India 2009
SciPy India 2009
 
Scientific Computing with Python Webinar: Traits
Scientific Computing with Python Webinar: TraitsScientific Computing with Python Webinar: Traits
Scientific Computing with Python Webinar: Traits
 
Scientific Computing with Python Webinar 9/18/2009:Curve Fitting
Scientific Computing with Python Webinar 9/18/2009:Curve FittingScientific Computing with Python Webinar 9/18/2009:Curve Fitting
Scientific Computing with Python Webinar 9/18/2009:Curve Fitting
 
Scientific Computing with Python Webinar --- August 28, 2009
Scientific Computing with Python Webinar --- August 28, 2009Scientific Computing with Python Webinar --- August 28, 2009
Scientific Computing with Python Webinar --- August 28, 2009
 
Scientific Computing with Python Webinar --- June 19, 2009
Scientific Computing with Python Webinar --- June 19, 2009Scientific Computing with Python Webinar --- June 19, 2009
Scientific Computing with Python Webinar --- June 19, 2009
 
Scientific Computing with Python Webinar --- May 22, 2009
Scientific Computing with Python Webinar --- May 22, 2009Scientific Computing with Python Webinar --- May 22, 2009
Scientific Computing with Python Webinar --- May 22, 2009
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Parallel Processing with IPython

  • 1. Parallel Processing with IPython January 22, 2010
  • 2. Enthought Python Distribution (EPD) MORE THAN SIXTY INTEGRATED PACKAGES • Python 2.6 • Repository access • Science (NumPy, SciPy, etc.) • Data Storage (HDF, NetCDF, etc.) • Plotting (Chaco, Matplotlib) • Networking (twisted) • Visualization (VTK, Mayavi) • User Interface (wxPython, Traits UI) • Multi-language Integration • Enthought Tool Suite (SWIG,Pyrex, f2py, weave) (Application Development Tools)
  • 3. Enthought Training Courses Python Basics, NumPy, SciPy, Matplotlib, Chaco, Traits, TraitsUI, …
  • 4. PyCon http://us.pycon.org/2010/tutorials/ Introduction to Traits Introduction to Enthought Tool Suite Fantastic deal (normally $700 at PyCon get the same material for $275) Corran Webster
  • 5. Upcoming Training Classes March 1 – 5, 2009 Python for Scientists and Engineers Austin, Texas, USA March 1 – 5, 2009 Python for Quants London, UK http://www.enthought.com/training/
  • 6. Parallel Processing with IPython 6
  • 7. IPython.kernel • IPython's interactive kernel provides a simple (but powerful) interface for task- based parallel programming. • Allows fast development and tuning of task-parallel algorithm to better utilize resources. 7
  • 8. Getting started --- local cluster UNIX and OSX (and now WINDOWS) manually WINDOWS # run ipcluster to start-up a # run ipcontroller and then # controller and a set of engines # ipengine for each desired engine $ ipcluster local –n 4 > start /B C:Python25Scriptsipcontroller.exe Your cluster is up and running. > start /B C:Python25Scriptsipengine.exe > start /B C:Python25Scriptsipengine.exe ... > start /B C:Python25Scriptsipengine.exe ... You can then cleanly stop the cluster from IPython using: 2009-02-11 23:58:26-0600 [-] Log opened. 2009-02-11 23:58:28-0600 [-] Using furl file: C:Documents mec.kill(controller=True) and Settingsdemo_ip ythonsecurityipcontroller-engine.furl You can also hit Ctrl-C to stop it, or use from the cmd 2009-02-11 23:58:28-0600 [-] registered engine with id: 3 line: 2009-02-11 23:58:28-0600 [-] distributing Tasks 2009-02-11 23:58:28-0600 [Negotiation,client] engine kill -INT 20465 registration succeeded, got id: 3 Creates several key-files in Creates several key-files in %HOME%_ipythonsecurity : ~/.ipython/security : ipcontroller-engine.furl ipcontroller-engine.furl ipcontroller-mec.furl ipcontroller-mec.furl ipcontroller-tc.furl ipcontroller-tc.furl 8
  • 9. Getting started -- distributed • Run ipcontroller on a host and create .furl files • Creates separate .furl files to be used by the different connections (engine, multiengine client, task client). • Places .furl files by default in ~/.ipython/security (UNIX or Mac OSX) or %HOME%_ipythonsecurity (Windows). • Takes --<connection>-furl-file=FILENAME options where <connection> is engine, multiengine, or task to place the .furl files somewhere else. • Ensure the ipcontroller-engine.furl file is available to each host that will run an engine and run ipengine on these hosts. • Either place it in the default security directory • Use the –furl-file=FILENAME option to ipengine • Ensure the multiengine (task) .furl file is available to each host that will run a multiengine (task) client. • Either place it in the default security directory • Pass the FILENAME as the first argument to the constructor 9
  • 10. Initialize client >>> from IPython.kernel import client MULTIENGINECLIENT TASKCLIENT # * allows fine-grained control # * does not expose individual # * each engine has an id number # engines # * more intuitive for beginners # * presents a load-balanced, # optional argument can be # fault-tolerant queue # location of mec furl-file # optional argument can be # created by the controller # location of tc furl-file >>> mec = client.MultiEngineClient() # created by the controller >>> mec.get_ids() >>> tc = client.TaskClient() [0 1 2 3] mec.map -- parallel map tc.map –- parallel map mec.parallel –- parallel function tc.parallel –- function decorator mec.execute -- execute in parallel tc.run -- run Tasks mec.push -- push data tc.get_task_result – get result mec.pull -- pull data mec.scatter -- spread out client.MapTask –- function-like mec.gather -- collect back client.StringTask –- code-string mec.kill -- kill engines and controller 10
  • 11. MultiEngineClient SCALAR FUNCTION  PARALLEL VECTORIZED FUNCTION # Using map >>> def func(x): ... return x**2.5 * (3*x – 2) # standard map >>> result = map(func, range(32)) # mec.map >>> parallel_result = mec.map(func, range(32)) # mec.parallel >>> pfunc = mec.parallel()(func) or using decorators @mec.parallel def pfunc(x): return x**2.5 * (3*x – 2) >>> parallel_result2 = pfunc(range(32)) 11
  • 12. TaskClient – Load Balancing SCALAR FUNCTION  PARALLEL VECTORIZED FUNCTION # Using map >>> def func(x): ... return x**2.5 * (3*x – 2) # standard map >>> result = map(func, range(32)) # mec.map >>> parallel_result = tc.map(func, range(32)) # mec.parallel >>> pfunc = tc.parallel()(func) or using decorators @tc.parallel def pfunc(x): return x**2.5 * (3*x – 2) >>> parallel_result2 = pfunc(range(32)) 12
  • 13. MultiEngineClient EXECUTE CODESTRING IN PARALLEL >>> from enthought.blocks.api import func2str # decorator that turns python-code into a string >>> @func2str ... def code(): ... import numpy as np ... a = np.random.randn(N,N) ... eigs, vals = np.linalg.eig(a) ... maxeig = max(abs(eigs)) >>> mec['N'] = 100 >>> result = mec.execute(code) >>> print mec['maxeig'] [10.471428625885835, 10.322386155553213, 10.237638983818622, 10.614715948426941] 13
  • 14. TaskClient – Load Balancing Queue EXECUTE CODESTRING IN PARALLEL >>> from enthought.blocks.api import func2str # decorator that turns python-code into a string >>> @func2str ... def code(): ... import numpy as np ... a = np.random.randn(N,N) ... eigs, vals = np.linalg.eig(a) ... maxeig = max(abs(eigs)) >>> task = client.StringTask(str(code), push={'N':100}, pull='maxeig') >>> ids = [tc.run(task) for i in range(4)] >>> res = [tc.get_task_result(id) for id in ids] >>> print [x['maxeig'] for x in res] [10.439989436983467, 10.250842410862729, 10.040835983392991, 10.603885977189803] 14
  • 15. Parallel FFT On Memory Mapped File Time Processors Speed Up (seconds) 1 11.75 1.0 2 6.06 1.9 4 3.36 3.5 8 2.50 4.7