More v0.7 woes - cannot import Plots in notebook with more than one worker

question

#1

I created a notebook kernel with two workers, and now cannot

import Plots

Here’s the error:

On worker 2:
InitError: LoadError: MethodError: no method matching show(::Base.PipeEndpoint, ::MIME{Symbol("text/html")}, ::String)
Closest candidates are:
  show(::IO, !Matched::MIME{Symbol("text/plain")}, ::Any) at sysimg.jl:195
  show(::IO, ::MIME{Symbol("text/html")}, !Matched::Method; kwtype) at methodshow.jl:241
  show(::IO, ::MIME{Symbol("text/html")}, !Matched::Base.MethodList) at methodshow.jl:290
  ...
display at ./multimedia.jl:211
display at ./multimedia.jl:301
display at ./multimedia.jl:179
top-level scope at /home/ubi/.julia/packages/Plots/ex9On/src/backends/plotly.jl:95
include at ./boot.jl:317 [inlined]
include_relative at ./loading.jl:1038
include at ./sysimg.jl:29 [inlined]
include at /home/ubi/.julia/packages/Plots/ex9On/src/Plots.jl:1 [inlined]
__init__ at /home/ubi/.julia/packages/Plots/ex9On/src/init.jl:2
_include_from_serialized at ./loading.jl:627
macro expansion at ./logging.jl:312 [inlined]
_require_search_from_serialized at ./loading.jl:698
_require at ./loading.jl:931
require at ./loading.jl:852
#2 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Distributed/src/Distributed.jl:77
#116 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Distributed/src/process_messages.jl:276
run_work_thunk at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Distributed/src/process_messages.jl:56
run_work_thunk at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Distributed/src/process_messages.jl:65
#102 at ./task.jl:262
in expression starting at /home/ubi/.julia/packages/Plots/ex9On/src/backends/plotly.jl:94
during initialization of module Plots
#remotecall_wait#154(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Function, ::Distributed.Worker) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Distributed/src/remotecall.jl:407
remotecall_wait(::Function, ::Distributed.Worker) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Distributed/src/remotecall.jl:398
#remotecall_wait#157(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Function, ::Int64) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Distributed/src/remotecall.jl:419
remotecall_wait(::Function, ::Int64) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Distributed/src/remotecall.jl:419
(::getfield(Distributed, Symbol("##1#3")){Base.PkgId})() at ./task.jl:262

...and 1 more exception(s).


Stacktrace:
 [1] sync_end(::Array{Any,1}) at ./task.jl:229
 [2] macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Distributed/src/Distributed.jl:75 [inlined]
 [3] macro expansion at ./task.jl:247 [inlined]
 [4] _require_callback(::Base.PkgId) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Distributed/src/Distributed.jl:74
 [5] #invokelatest#1 at ./essentials.jl:691 [inlined]
 [6] invokelatest at ./essentials.jl:690 [inlined]
 [7] require(::Base.PkgId) at ./loading.jl:855
 [8] macro expansion at ./logging.jl:311 [inlined]
 [9] require(::Module, ::Symbol) at ./loading.jl:834
 [10] top-level scope at In[2]:1

I don’t even want to use the Plotly backend, and my next statement would be

Plots.gr()

I also don’t want to do plotting in parallel, just computation using SharedArray and the macros @everywhere include ... and @sync @parallel for ... later on in the notebook.

Please help!

Thanks in advance.


#2

Seems odd given that you say you’re not calling @everywhere import Plots (not sure whether behaviour is different in notebooks!?) but why not simply do:

import Plots
Plots.gr() # everything done on one process so far so should work

using Distributed, SharedArrays
addprocs(2)
# parallel computations start here

#3

Thanks for responding. I was under the impression that I had to use IJulia.installkernel to allow multiple workers in a notebook. If I can start up the notebook with the regular Julia-0.7 kernel, then addprocs later, that might solve my problem! I’ll try it now . . .


#4

As far as I know this should work (related IJulia issue)


#5

Distributed.addprocs works! Thanks.

I’m still getting warnings about calling Base.@everywhere even though I’m clearly calling Distributed.@everywhere. But my calculations appear to be correct and ran in parallel.

(I don’t like to use using because I’m still learning and want to be clear which versions of functions I’m running.)