Can joblib.Parallel work in interactive environments (e.g., IPython Notebook) in Windows?
See original GitHub issueThe doc example
from joblib import Parallel, delayed
Parallel(n_jobs=2)(delayed(sqrt)(i ** 2) for i in range(10))
worked with importable functions like sqrt
, but not with those defined in interactive environments including IPython Notebook and IPython console:
def myfunc(x):
return sqrt(x)
Parallel(n_jobs=2)(delayed(myfunc)(i ** 2) for i in range(10))
and raised the following error:
AttributeError: 'module' object has no attribute 'myfunc'
I’m running Python 2.7.7, Anaconda 2.0.1 (64-bit), Windows 7 SP1 (64-bit), IPython 2.1.0, joblib 0.8.4. The same works smoothly in Linux.
Issue Analytics
- State:
- Created 9 years ago
- Reactions:1
- Comments:27 (15 by maintainers)
Top Results From Across the Web
Embarrassingly parallel for loops - Joblib - Read the Docs
Parallel uses the 'loky' backend module to start separate Python worker processes to ... In this case joblib will automatically use the "threading"...
Read more >Use joblib - Python Numerical Methods
We can see the parallel part of the code becomes one line by using the joblib library, which is very convenient. The Parallel...
Read more >Print from within Joblib Parallel function in Jupyter notebook
Is it possible to print things or debug when using Parallel in a Jupyter notebook. Here is my code import pandas as pd...
Read more >joblib Documentation - Read the Docs
The vision is to provide tools to easily achieve better performance and reproducibility when working with long running jobs.
Read more >Multiprocessing in Python on Windows and Jupyter/Ipython
This code should work perfectly fine on linux, but, If you run it on python shell on Windows (cmd → python), you will...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
AFAIR this is not expected to work under Windows neither with Python 2 nor Python 3.
Putting the method in a module is the cleanest work-around. If that helps, you have a built-in editor in Jupyter these days. If you insist of having all your code in the same notebook you can use a combination of
%%file
to write into an external file andimp.reload
to make sure you always use the latest version of the module.For completeness, the long-term fix for this is to use dill to serialize the function inside Parallel. The idea would be to just take #240 and only use dill to serialise the function inside Parallel. This is something we really want to do so that we can switch to fork_server as the default joblib start method. We just haven’t had the time to do it … PR more than welcome !