multiprocessing python
Asked Answered
T

3

5

What are the simplest way to use all cores off a computer for a python program ? In particular, I would want to parallelize a numpy function (which already exists). Is there something like openmp under fortran in python ?

Tartarean answered 12/3, 2012 at 15:13 Comment(1)
packages.python.org/joblibChilblain
M
7

Check out the multiprocessing library. It even allows to spread work across multiple computers.

Mirnamirror answered 12/3, 2012 at 15:15 Comment(0)
S
2

It depends on what you want to do and how numpy is compiled on your machine (in some cases, some multicore use will be automatic). See this page for details.

Sped answered 12/3, 2012 at 15:27 Comment(0)
M
0

It may or may not fit to your specific problem you want to solve, but I personally find the ipython shell's parallel infrastructure quite attractive. It is relatively easy to set up an ipcluster on localhost (see in the manual).

You can wrap your function you wish to evaluate into a @parallel decorator for example and its evaluation will be distributed among many cores (see the Quick and easy parallelism section of the manual)

Maury answered 15/3, 2012 at 9:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.