Skip to content

MATLAB.MEngineError("failed to put variable A into MATLAB session (err = 1)") #225

Closed
@dhtantoy

Description

@dhtantoy

I met an issue when I relegated the program to the background using nohup.

ERROR: LoadError: MATLAB.MEngineError("failed to put variable A into MATLAB session (err = 1)")
Stacktrace:
  [1] put_variable(session::MATLAB.MSession, name::Symbol, v::MATLAB.MxArray)
    @ MATLAB ~/.julia/packages/MATLAB/xBhSu/src/engine.jl:153
  [2] put_variable
    @ ~/.julia/packages/MATLAB/xBhSu/src/engine.jl:157 [inlined]
  [3] ......

I need to frequently input a matrix A and vector b into the MATLAB session for resolution. The code is like

function (solver::MatlabSolver)(A, b)
    # `solver` has a field `s` which is an MSession
    put_variable(solver.s, :A, A)
    put_variable(solver.s, :b, b)
    eval_string(solver.s, "u = A \\ b;")
    uh = get_mvariable(solver.s, :u) |> jvector
    return uh
end

Everything began smoothly, but when I relegated the program to the background, the aforementioned issue would manifest after approximately several dozen iterations.
Matlab version:

MATLAB Version: 9.11.0.1809720 (R2021b) Update 1
MATLAB License Number: xxx
Operating System: Linux 5.14.0-70.26.1.el9_0.x86_64 #1 SMP PREEMPT Tue Sep 20 17:53:31 UTC 2022 x86_64
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode

julia version:

julia version 1.10.2

MATLAB.jl version:

[10e44e05] MATLAB v0.8.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions