Mar*_*994 5 parallel-processing julia
我有一个在我的机器上编写的本地模块,我正在使用julia 1.7,当我想使用这个模块时,我会写这样的内容:
@everywhere include("Foo.jl")
using .Foo
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
UndefVarError: Foo not defined
Stacktrace:
[1] top-level scope
@ /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Distributed/src/macros.jl:200
[2] eval
@ ./boot.jl:373 [inlined]
[3] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base ./loading.jl:1196
Run Code Online (Sandbox Code Playgroud)
现在我不明白为什么它没有定义,即使它是在本地计算机的同一目录中编写的。
假设这只是一个模块(我运行此代码addprocs(4)):
shell> more Foo.jl
module Foo
x = 5
end
julia> @everywhere include("Foo.jl")
julia> @everywhere using .Foo
Run Code Online (Sandbox Code Playgroud)
如果您有本地包:
@everywhere using Pkg
@everywhere pkg"activate ."
@everywhere using Pkg
Run Code Online (Sandbox Code Playgroud)
在这两种情况下,路径都需要可供所有工作人员使用。