Through some trials and errors I realized that modules, which are loaded with
using, are also loaded on the already existing workers. Therefore the following code runs without an error:
using Distributed addprocs(2) using PyPlot pmap(workers()) do w w, myid(), PyPlot.version end
I find this behavior quite inconvenient because in a situation with many workers (to generate some data) connected to one jupyter notebook kernel (to analyze this data) I rather prefer not to load a plotting package on all workers.
Somewhat inconsistently to this behavior I found out that a module which is already loaded in the main process will not be loaded on all workers, if it was include with
using before the workers were created. Julia is very smart and seems to know that the module is already there in process 1, however does not load it into the workers.
Therefore this code gives errors:
using Distributed using PyPlot addprocs(2) using PyPlot pmap(workers()) do w w, myid(), PyPlot.version end
which certainly can be resolved by dressing the second
using Distributed using PyPlot addprocs(2) @everywhere using PyPlot pmap(workers()) do w w, myid(), PyPlot.version end
Is this intended the intended behavior? Is there a way to load a module only on the local process even if there are already workers running?