JuliaSmoothOptimizers / OptimizationProblems.jl

Optimization Problems for Julia
Other
88 stars 48 forks source link

StackOverFlow Error occurs when using the module with multiple processes. #213

Closed MonssafToukal closed 1 year ago

MonssafToukal commented 2 years ago

I wanted to use OptimizationProblems.jl to benchmark some solvers in parallel, but I get a strange error.

using Distributed
addprocs(2; exeflags="--project=$(@__DIR__)")

@everywhere begin
  using ADNLPModels, OptimizationProblems, OptimizationProblems.ADNLPProblems
end

This gives the following error:

      From worker 2:    ┌ Warning: Error requiring `ADNLPModels` from `OptimizationProblems.ADNLPProblems`
      From worker 2:    │   exception =
      From worker 2:    │    LoadError: StackOverflowError:
      From worker 2:    │    Stacktrace:
      From worker 2:    │      [1] promote_typeof(::Float64, ::Float64, ::Vararg{Any}) (repeats 13902 times)
      From worker 2:    │        @ Base ./promotion.jl:330
      From worker 2:    │      [2] hvcat(::NTuple{4199, Int64}, ::Int64, ::Vararg{Number})
      From worker 2:    │        @ Base ./abstractarray.jl:2019
      From worker 2:    │      [3] top-level scope
      From worker 2:    │        @ ~/.julia/packages/OptimizationProblems/nfPUU/data/tetra_duct12.jl:1
      From worker 2:    │      [4] include(mod::Module, _path::String)
      From worker 2:    │        @ Base ./Base.jl:418
      From worker 2:    │      [5] include(x::String)
      From worker 2:    │        @ OptimizationProblems.ADNLPProblems ~/.julia/packages/OptimizationProblems/nfPUU/src/ADNLPProblems/ADNLPProblems.jl:1
      From worker 2:    │      [6] top-level scope
      From worker 2:    │        @ ~/.julia/packages/OptimizationProblems/nfPUU/src/ADNLPProblems/tetra.jl:71
      From worker 2:    │      [7] include(mod::Module, _path::String)
      From worker 2:    │        @ Base ./Base.jl:418
      From worker 2:    │      [8] include(x::String)
      From worker 2:    │        @ OptimizationProblems.ADNLPProblems ~/.julia/packages/OptimizationProblems/nfPUU/src/ADNLPProblems/ADNLPProblems.jl:1
      From worker 2:    │      [9] top-level scope
      From worker 2:    │        @ ~/.julia/packages/OptimizationProblems/nfPUU/src/ADNLPProblems/ADNLPProblems.jl:15
      From worker 2:    │     [10] eval
      From worker 2:    │        @ ./boot.jl:373 [inlined]
      From worker 2:    │     [11] eval
      From worker 2:    │        @ ~/.julia/packages/OptimizationProblems/nfPUU/src/ADNLPProblems/ADNLPProblems.jl:1 [inlined]
      From worker 2:    │     [12] (::OptimizationProblems.ADNLPProblems.var"#4#8")()
      From worker 2:    │        @ OptimizationProblems.ADNLPProblems ~/.julia/packages/Requires/Z8rfN/src/require.jl:101
      From worker 2:    │     [13] macro expansion
      From worker 2:    │        @ timing.jl:299 [inlined]
      From worker 2:    │     [14] err(f::Any, listener::Module, modname::String, file::String, line::Any)
      From worker 2:    │        @ Requires ~/.julia/packages/Requires/Z8rfN/src/require.jl:47
      From worker 2:    │     [15] (::OptimizationProblems.ADNLPProblems.var"#3#7")()
      From worker 2:    │        @ OptimizationProblems.ADNLPProblems ~/.julia/packages/Requires/Z8rfN/src/require.jl:100
      From worker 2:    │     [16] withpath(f::Any, path::String)
      From worker 2:    │        @ Requires ~/.julia/packages/Requires/Z8rfN/src/require.jl:37
      From worker 2:    │     [17] (::OptimizationProblems.ADNLPProblems.var"#2#6")()
      From worker 2:    │        @ OptimizationProblems.ADNLPProblems ~/.julia/packages/Requires/Z8rfN/src/require.jl:99
      From worker 2:    │     [18] listenpkg(f::Any, pkg::Base.PkgId)
      From worker 2:    │        @ Requires ~/.julia/packages/Requires/Z8rfN/src/require.jl:20
      From worker 2:    │     [19] macro expansion
      From worker 2:    │        @ ~/.julia/packages/Requires/Z8rfN/src/require.jl:98 [inlined]
      From worker 2:    │     [20] macro expansion
      From worker 2:    │        @ ~/.julia/packages/OptimizationProblems/nfPUU/src/ADNLPProblems/ADNLPProblems.jl:8 [inlined]
      From worker 2:    │     [21] (::OptimizationProblems.ADNLPProblems.var"#1#5")()
      From worker 2:    │        @ OptimizationProblems.ADNLPProblems ~/.julia/packages/Requires/Z8rfN/src/init.jl:11
      From worker 2:    │     [22] __init__()
      From worker 2:    │        @ OptimizationProblems.ADNLPProblems ~/.julia/packages/Requires/Z8rfN/src/init.jl:18
      From worker 2:    │     [23] _include_from_serialized(path::String, depmods::Vector{Any})
      From worker 2:    │        @ Base ./loading.jl:768
      From worker 2:    │     [24] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String)
      From worker 2:    │        @ Base ./loading.jl:854
      From worker 2:    │     [25] _require(pkg::Base.PkgId)
      From worker 2:    │        @ Base ./loading.jl:1097
      From worker 2:    │     [26] require(uuidkey::Base.PkgId)
      From worker 2:    │        @ Base ./loading.jl:1013
      From worker 2:    │     [27] (::Distributed.var"#1#2"{Base.PkgId})()
      From worker 2:    │        @ Distributed /apps/local-fci/tools/julia-1.7.1/share/julia/stdlib/v1.7/Distributed/src/Distributed.jl:79
      From worker 2:    │     [28] (::Distributed.var"#103#104"{Distributed.CallMsg{:call}})()
      From worker 2:    │        @ Distributed /apps/local-fci/tools/julia-1.7.1/share/julia/stdlib/v1.7/Distributed/src/process_messages.jl:274
      From worker 2:    │     [29] run_work_thunk(thunk::Distributed.var"#103#104"{Distributed.CallMsg{:call}}, print_error::Bool)
      From worker 2:    │        @ Distributed /apps/local-fci/tools/julia-1.7.1/share/julia/stdlib/v1.7/Distributed/src/process_messages.jl:63
      From worker 2:    │     [30] run_work_thunk(rv::Distributed.RemoteValue, thunk::Function)
      From worker 2:    │        @ Distributed /apps/local-fci/tools/julia-1.7.1/share/julia/stdlib/v1.7/Distributed/src/process_messages.jl:72
      From worker 2:    │     [31] (::Distributed.var"#96#98"{Distributed.RemoteValue, Distributed.var"#103#104"{Distributed.CallMsg{:call}}})()
      From worker 2:    │        @ Distributed ./task.jl:423
      From worker 2:    │    in expression starting at /home/motoug/.julia/packages/OptimizationProblems/nfPUU/data/tetra_duct12.jl:1
      From worker 2:    │    in expression starting at /home/motoug/.julia/packages/OptimizationProblems/nfPUU/src/ADNLPProblems/tetra.jl:71
      From worker 2:    └ @ Requires ~/.julia/packages/Requires/Z8rfN/src/require.jl:51

You can reproduce the error without having multiple processes by simply doing this:

using Distributed
@everywhere begin
  include("tetra_duct12.jl")
end

If you simply do include("tetra_duct12.jl") without the @everywhere macro, there is no error. There is an open issue on the same error message: https://github.com/JuliaLang/julia/issues/45454