Instructor: Philip Austin (Earth, Ocean and Atmospheric Sciences, UBC)
Title: Parallelization in Python 3 with large datasets
Duration: 3 hours
Target audience: Researchers interested in Python programming on multiple core machines.
Level: Intermediate
Prerequisites:
- Some familiarity with Jupyter notebooks, Python and numpy at the level of Jake Vanderplas' Whirlwind tour of Python or this week's Tuesday introduction to Jupyter by Patrick Wall
Course plan:
- The objective is to learn how to write shared-memory Python programs that make use of multiple cores on a single node. The tutorial will introduce several python modules that schedule operations and manage data to simplify multiprocessing with Python.
- Benchmarking parallel code
- Understanding the global interpreter lock (GIL)
- Multiprocessing and multithreading with joblib
- Checkpointing/restarting multiprocessor jobs
- Multithreaded file i/o with zarr and parquet
- Writing extensions that release the GIL:
- Using numba
- Using cython
- Using C++ and pybind11 with xtensor-python
- Using dask/xarray to analyze out-of-core datasets
- Visualizing parallelization with dask
- Setting up a conda-forge environment for parallel computing
Setup requirements:
- A laptop with the x2go client installed
- An account on grex
- .bashrc which adds python 3.6.1 and g++ 5.2 to the PATH
I'd encourage you to do a local python install on your laptop, to make sure we don't get hit by bandwidth limitations or competition for cpus on grex nodes.
We will need python 3.6 from conda-forge. To get it:
-
Download miniconda 3.6 from https://conda.io/miniconda.html
-
When prompted, set the install directory as something like /Users/phil/mini36, with the install for just yourself, but ignore the installer warning and make this your default python. To reverse that decision it is easy to edit either your .bashrc/.bash_profile (for OSX) or your PATH environmental varialbe (for Windows 10) and give higher priority to some other python executable. It will make the following step easier, however if this conda-forge python is your default for the class and the install below
-
Set conda-forge as your default repository and upgrade your python by doing the following. Open a bash terminal (OSX) or a cmd shell (Windows) and type:
conda config --prepend channels conda-forgefollowed by:
conda update --all -
Once the update completes, copy the contents of https://github.com/phaustin/parallel_python_course/blob/master/conda_packages.txt into a local file named conda_packages.txt and install those packages by typing:
conda install --file conda_packages.txt
The odds of this going smoothly for everyone are obviously close to zero. If all else fails you can follow along using a browser to point to my html files, and get the jupyter notebooks working at your leisure after class. All the notebooks we work with during the tutorial will be available in the github repository, and from my bison account. Feel free to email me at paustin@eoas.ubc.ca with any questions.
-
bookmark the lecture notes at https://clouds.eos.ubc.ca/~phil/courses/parallel_python/
-
clone the course git repository with the notebooks by typing:
git clone https://github.com/phaustin/parallel_python_course.git -
My anaconda channel is phaustin