# Dagger error, parallel computing

**URL:** <https://discourse.julialang.org/t/dagger-error-parallel-computing/8440>\
**Category:** General Usage\
**Tags:** package\
**Created:** [January 17, 2018, 5:58pm UTC](https://discourse.julialang.org/t/dagger-error-parallel-computing/8440 "2018-01-17T17:58:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhangliye](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zhangliye/32/3208_2.png) [@zhangliye](https://discourse.julialang.org/u/zhangliye)\
**Post date:** [January 17, 2018, 5:58pm UTC](https://discourse.julialang.org/t/dagger-error-parallel-computing/8440/1 "2018-01-17T17:58:45Z")

</div>

When I am using Dagger to run functions parallelly. I got errors. The code is as follows. Can anyone show how to run functions parallelly using Dagger?  
Thanks!

```julia
addprocs()
using Dagger

function f1(x)
    sleep(2)
    rand()+x
end 

vs = [rand(Int) for i in 1:10];
cks = Any[]
for v in vs
    push!(cks, delayed(f1)(v))
end 

for k in cks
    @show collect(k)
end

```

Running on Windows 7, 64bit,Julia 0.61, latest Dagger

error:  
On worker 2:  
**UndefVarError: #f1 not defined**  
deserialize\_datatype at .\serialize.jl:973  
handle\_deserialize at .\serialize.jl:677  
deserialize at .\serialize.jl:637  
handle\_deserialize at .\serialize.jl:684  
deserialize at .\serialize.jl:637  
#1 at .\serialize.jl:739  
ntuple at .\tuple.jl:108  
deserialize\_tuple at .\serialize.jl:739  
handle\_deserialize at .\serialize.jl:667  
deserialize\_msg at .\distributed\messages.jl:98  
message\_handler\_loop at .\distributed\process\_messages.jl:161  
process\_tcp\_streams at .\distributed\process\_messages.jl:118  
#99 at .\event.jl:73  
#remotecall\_fetch#141(::Array{Any,1}, ::Function, ::Function, ::Base.Distributed.Worker, ::Dagger.Context, ::Vararg{Any,N} where N) at .\distributed\remotecall.jl:354  
remotecall\_fetch(::Function, ::Base.Distributed.Worker, ::Dagger.Context, ::Vararg{Any,N} where N) at .\distributed\remotecall.jl:346  
#remotecall\_fetch#144(::Array{Any,1}, ::Function, ::Function, ::Int64, ::Dagger.Context, ::Vararg{Any,N} where N) at .\distributed\remotecall.jl:367  
macro expansion at E:\julia-package\v0.6\Dagger\src\compute.jl:332 [inlined]  
(::Dagger.##69#70{Dagger.Context,Dagger.OSProc,Int64,#f1,Tuple{Int64},Channel{Any},Bool,Bool,Bool})() at .\event.jl:73

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [January 17, 2018, 6:36pm UTC](https://discourse.julialang.org/t/dagger-error-parallel-computing/8440/2 "2018-01-17T18:36:45Z")

</div>

try:

```nohighlight
@everywhere function f1(x)
           sleep(2)
           rand()+x
end 

```

You work with multiple processes here, which involves the pain to make your functions available on all processes.

---

<div class="post-metadata">

**Author:** ![zhangliye](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zhangliye/32/3208_2.png) [@zhangliye](https://discourse.julialang.org/u/zhangliye)\
**Post date:** [January 18, 2018, 5:01am UTC](https://discourse.julialang.org/t/dagger-error-parallel-computing/8440/3 "2018-01-18T05:01:25Z")

</div>

@sdanisch Thank you so much! It works.
