Inconsistency between macos and linux for neuron under multiprocessing #2100
-
ContextOverview of the issueWhen in a subprocess, neuron dt is the same as in the main process in linux, while it is reset to its default value in macos Expected result/behaviorI would expect neuron to behave the same on both macos and linux. I would also like for neuron dt not to be reset to its default value when in a subprocess. NEURON setup
Minimal working example - MWE
import neuron
import multiprocessing
def show_dt():
print(neuron.h.dt)
if __name__ == '__main__':
neuron.h.dt = 0.1
show_dt()
proc = multiprocessing.Process(target=show_dt)
proc.start()
proc.join()
print("end") Logsoutput on linux:
ouptut on macos:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
thanks @AurelienJaquier for the report with a reproducer! I believe this is related to the differences in multi-processing module itself on Linux vs macOS:
If you explicitly set the start method (e.g. |
Beta Was this translation helpful? Give feedback.
-
Thank you very much for your detailed response @pramodk ! I'll close this issue. |
Beta Was this translation helpful? Give feedback.
-
Hi, I think the underlying issue is the following: |
Beta Was this translation helpful? Give feedback.
-
Since the docs for
using |
Beta Was this translation helpful? Give feedback.
thanks @AurelienJaquier for the report with a reproducer!
I believe this is related to the differences in multi-processing module itself on Linux vs macOS:
fork mode
(default for Unix): all resources of the parent are inherited by the child processspawn mode
(default for MacOS): child process will only inherit those resources necessary to run the process objects run() methodIf you explicitly set the start method (e.g.
multiprocessing.set_start_method('fork')
) then you should see the same behaviour.