R session crash if plan is not changed back to sequential after using multisession (in linux) #690
Replies: 4 comments
-
I don't have much knowledge in this area, but one thing you could try, both to narrow in on the root issue of the crash and as an alternative to "multisession" is to install the package "future.callr" and then use the following plan (instead of the "multisession" plan):
If you don't switch back to sequential at the end, do things still work well with the above plan? |
Beta Was this translation helpful? Give feedback.
-
@scottkosty I can use this workaround for the moment for my own development, but I would like to know why is this happening with plans from |
Beta Was this translation helpful? Give feedback.
-
The
Yes, this is expected (as explained above). As @scottkosty suggested, you can use the
Without known more details, that sounds like a problem with RStudio. Something rings a bell here, and I might have heard something about this related to the parallel package way back, but I might also misremember it. Putting aside everything with the Futureverse, can you reproduce the crash if you simply start a vanilla PSOCK cluster using: cl <- parallel::makeCluster(16)
print(cl) and then restart the RStudio session the way that causes it to crash with
You probably meant "process" or "parallel worker" instead of "fork" here; note that |
Beta Was this translation helpful? Give feedback.
-
Understood, it makes sense after your comment and a more careful read of the docs.
It crash exactly the same as in the initial comment, so you are right, seems like a problem with Thanks for your time and sorry for the false alarm. |
Beta Was this translation helpful? Give feedback.
-
(Please use https://github.com/HenrikBengtsson/future/discussions for Q&A)
Describe the bug
When using
future::plan(future::multisession)
in linux, this creates as R workers as especified in the workers arguments that are not closed until the plan is changed back to sequential or the session is closed/reinitialized. The latter in Rstudio almost always results in a crash of the R sessionReproduce example
Simply changing the plan to multisession creates the issue. R session processes can be monitored with
htop
,btm
or the console system monitor of your choice:btm screenshot in a freshly new session:
btm screenshot after changing plan:
As it can seen, R processes appear.
btm screenshot showing that memory is still used in each fork after computation ends:
Restarting the session (building and restarting for package development, changing project...) crash R session causing it to restart and can lead to data loss.
Changing the plan to sequential before exiting the session removes sucessfully the R workers
btm screenshot after changing to sequential:
Expected behavior
When ussing
plan(multisession)
I expect those processes to be terminated after computation finish and results are gathered, or at least that RStudio does not crash if plan is not changed back to sequential before restarting/closing the session.Session information
Created on 2023-06-23 with reprex v2.0.2
** Future session info when in sequential**
Created on 2023-06-23 with reprex v2.0.2
** Future session info when in multiprocess**
Created on 2023-06-23 with reprex v2.0.2
Beta Was this translation helpful? Give feedback.
All reactions