Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning IPython for Interactive Computing and Data Visualization, Second Edition

You're reading from  Learning IPython for Interactive Computing and Data Visualization, Second Edition

Product type Book
Published in Oct 2015
Publisher
ISBN-13 9781783986989
Pages 200 pages
Edition 1st Edition
Languages
Author (1):
Cyrille Rossant Cyrille Rossant
Profile icon Cyrille Rossant

Distributing tasks on several cores with IPython.parallel


In the previous sections, we covered a few methods to accelerate Python code. Here, we will see how to run multiple tasks in parallel on a multicore computer. IPython implements highly-powerful and user-friendly facilities for interactive parallel computing in the Notebook.

We first need to install ipyparallel (also called IPython.parallel) with conda install ipyparallel. Next, let's import NumPy and ipyparallel:

In [1]: import numpy as np
        # ipyparallel was IPython.parallel before IPython 4.0
        from ipyparallel import Client

To use IPython.parallel, we need to launch a few engines.

The first way to do it is to run ipcluster start in the terminal.

You can also launch engines from the Notebook dashboard. However, you first need to add c.NotebookApp.server_extensions.append('ipyparallel.nbextension') in the file ~/.jupyter/jupyter_notebook_config.py (you may need to create this file). Then, from the Notebook dashboard (accessible...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}