Error when I use the function distribute(array) from the libray DistributedArrays

When I create an array and after I use the distribute() function from the Distributed Arrays library, I get this error:

ERROR: On worker 2:
KeyError: key DistributedArrays [aaf54ef3-cdf8-58ed-94cc-d582ad619b94] not found
getindex at .\dict.jl:478 [inlined]
root_module at .\loading.jl:892 [inlined]
deserialize_module at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Serialization\src\Serialization.jl:831
handle_deserialize at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Serialization\src\Serialization.jl:764
deserialize at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Serialization\src\Serialization.jl:703
deserialize_datatype at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Serialization\src\Serialization.jl:1050
handle_deserialize at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Serialization\src\Serialization.jl:743
deserialize at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Serialization\src\Serialization.jl:703
handle_deserialize at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Serialization\src\Serialization.jl:750
deserialize_msg at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Serialization\src\Serialization.jl:703
#invokelatest#1 at .\essentials.jl:686 [inlined]
invokelatest at .\essentials.jl:685 [inlined]
message_handler_loop at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Distributed\src\process_messages.jl:160
process_tcp_streams at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Distributed\src\process_messages.jl:117
#105 at .\task.jl:259
#remotecall_fetch#149(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Function, ::Distributed.Worker, ::Function, ::Vararg{Any,N} where N) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Distributed\src\remotecall.jl:379
remotecall_fetch(::Function, ::Distributed.Worker, ::Function, ::Vararg{Any,N} where N) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Distributed\src\remotecall.jl:371
#remotecall_fetch#152(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Function, ::Int64, ::Function, ::Vararg{Any,N} where N) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Distributed\src\remotecall.jl:392
remotecall_fetch(::Function, ::Int64, ::Function, ::Vararg{Any,N} where N) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Distributed\src\remotecall.jl:392
macro expansion at C:\Users\Daniele.julia\packages\DistributedArrays\XV7NS\src\darray.jl:87 [inlined]
(::getfield(DistributedArrays, Symbol(“##1#2”)){Tuple{Int64,Int64},getfield(DistributedArrays, Symbol(“##63#65”)){DistributedArrays.DestinationSerializer},Tuple{Int64,Int64},Array{Int64,2},Array{Tuple{UnitRange{Int64},UnitRange{Int64}},2},Array{Array{Int64,1},1},Channel{Any}})() at .\task.jl:259

…and 3 more exception(s).

Stacktrace:
[1] sync_end(::Array{Any,1}) at .\task.jl:226
[2] macro expansion at C:\Users\Daniele.julia\packages\DistributedArrays\XV7NS\src\darray.jl:83 [inlined]
[3] macro expansion at .\task.jl:244 [inlined]
[4] DArray(::Tuple{Int64,Int64}, ::Function, ::Tuple{Int64,Int64}, ::Array{Int64,2}, ::Array{Tuple{UnitRange{Int64},UnitRange{Int64}},2}, ::Array{Array{Int64,1},1}) at C:\Users\Daniele.julia\packages\DistributedArrays\XV7NS\src\darray.jl:82
[5] DArray(::Function, ::Tuple{Int64,Int64}, ::Array{Int64,1}, ::Array{Int64,1}) at C:\Users\Daniele.julia\packages\DistributedArrays\XV7NS\src\darray.jl:169
[6] #distribute#61(::Array{Int64,1}, ::Array{Int64,1}, ::Function, ::Array{Int64,2}) at C:\Users\Daniele.julia\packages\DistributedArrays\XV7NS\src\darray.jl:501
[7] distribute(::Array{Int64,2}) at C:\Users\Daniele.julia\packages\DistributedArrays\XV7NS\src\darray.jl:494
[8] top-level scope at none:0

1 Like

I’m facing a similar issue. Any idea?

The issue happens when I add child processes from a function within a module. The child processes do not see the module itself but I couldn’t use the using statement either because it’s inside a function. Moving to the addprocs call out to a script avoids this problem. I’m wondering however if there’s a better way to do this though…

2 Likes

According to this post the issue is that the processes are likely added after the “@everywhere using …” commands. I found that by reorganizing my import statements I could make this error go away. Specifically make sure you addprocs first like

using Distributed
addprocs(4)
@everywhere using DistributedArrays
import("myfile.jl")
2 Likes