-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Parallel printing to stderr #700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
As a data point, I have added explicit flushing of stderr in a local copy of joblib (as suggested by @ellisonbg according to scikit-learn/scikit-learn#5811), but it didn't solve the problem. Technically, stderr shouldn't be buffered (according to Unix specs), so in theory it shouldn't make a difference. |
The author means plain IPython, using |
As I looked a bit at these problems a long time ago, when I was working on the IPython Qt console, I have a hunch that this is due to the way we capture outputs of processes. It's probably not trivial to fix (sorry, :$). I suspect that using some Unix-specific stuff (ie not Python such as stream redirection to a named pipe) might help on the Unix side, and maybe some windows-specific stuff too (the equivalent in Windows, which I don't understand well). The good news that solving such a problem is certainly possible, as something like travis-CI captures output and redirects to web without any problem. |
hm... @minrk might have some insights? |
There is some funkiness in how we capture output from forked processes that proves to be quite fragile. I will try to investigate what's going wrong in this case. |
Once I finish it, this should be fixed by ipython/ipykernel#85 |
Closed #700 via ipython/ipykernel#85.
Good job! Thanks
|
Awesome! Thanks guys! |
When I run @stefdoerr's example, it now correctly prints during computation. However, if I print within a function myself instead of just having the from joblib import Parallel, delayed
def f(x):
print(f"x = {x}")
return x
Parallel(n_jobs=2)(delayed(f)(x) for x in range(5)) doesn't print anything. However, if I set |
I'll echo this: printing to stdout and stderr from within forked processes is hidden from the Jupyter notebook output and prints instead to the notebook backend (which can be done manually by Neither of the following print anything to the notebook output.
but both of these work
|
It seems to me that this work with If the start method for But this is very hard to come up with a good solution to propagate monkey patching in the child process. In this is a similar problem with warning filters and globals propagation. In case, a potential solution could be to modify |
I believe this is the same issue discussed here: https://stackoverflow.com/questions/55955330/printed-output-not-displayed-when-using-joblib-in-jupyter-notebook Edit: Edit2: |
Hello, I am using joblib.Parallel to parallelize my computations. Parallel is able to print out to stderr the progress of the calculations. This works fine in IPython console where the progress is updated every few seconds, but in jupyter notebook the progress is only printed once the computation has completed.
If you want to try it:
I talked with the joblib devs and they said that it must be a problem in the Notebook since stderr should be printed directly.
It works fine in the Notebook as well if you put n_jobs=1 which just runs it serially so it seems like Notebook doesn't update stderr when there is threading.
I would appreciate any insight :)
The text was updated successfully, but these errors were encountered: