JuliaInterop / JuliaInterop/MATLAB.jl

Fails to put large variables to the Matlab engine

Open
#154 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
286
Forks
64
PR merge metrics
No merged PRs in 30d

Description

Hi, I wrote a small script that uses Matlab's nnmf function to factorize a large matrix (~5000 rows by 60000 columns). I generate the matrix, called V, in Julia and I use the following code to call the function:
w, h, rss = mxcall(:nnmf, 3, V, 2)

Unfortunately this generates the error:

ERROR: MATLAB.MEngineError("failed to put variable jx_nnmf_arg_in_1 into MATLAB session (err = 1)")
Stacktrace:
[1] put_variable(::MSession, ::Symbol, ::Array{Float64,2}) at C:\Users\St. Elmo.julia\packages\MATLAB\SljED\src\engine.jl:153
[2] mxcall(::MSession, ::Symbol, ::Int64, ::Array{Float64,2}, ::Vararg{Any,N} where N) at C:\Users\St. Elmo.julia\packages\MATLAB\SljED\src\engine.jl:283
[3] mxcall(::Symbol, ::Int64, ::Array{Float64,2}, ::Int64) at C:\Users\St. Elmo.julia\packages\MATLAB\SljED\src\engine.jl:317
[4] top-level scope at none:0

I tried this on multiple Julia versions (6.4 and 1.0.2) to the same effect. When I run the same function with the same matrix in Matlab it works. My suspicion is that the large matrix is causing the problem. Is there a way around it?

Ps. This approach works on smaller input matrices.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/engine.jl around put_variable (line 153) and mxcall (lines 283 and 317), then reproduce the failure with the reported 5000-by-60000 Float64 matrix and a smaller input. Compare the MATLAB engine transfer behavior; done means identifying a supported fix or documented workaround for large variables, with the smaller-matrix behavior preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia, matlab
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.