matlab.eng​ine.Engine​Error: MATLAB function cannot be evaluated, MATLAB crash

조회 수: 20 (최근 30일)
Loc
Loc 2023년 8월 2일
답변: Ninad 2023년 8월 29일
Hi,
I have a docker image running on A100 machine. The image is constructed based on r2021a MATLAB version, and installed matlab.engine to run in Python environment 2.7 version.
The scripts is written in MATLAB but running in Python. However it's going to crash in running out of memory as I suppose to be. Here is the Error Pop up:
import matlab.engine
eng = matlab.engine.start_matlab()
eng.eval('clear', nargout=0)
eng.eval('clc', nargout=0)
eng.run('/mnt/Tsunami_HHD/newloci/NativeEnsembleWeb_copy/getFeature/importlib.m', nargout=0)
...
df_m = eng.getFeatures_MT(MT_file)
eng.quit()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/miniconda3/envs/py27/lib/python2.7/site-packages/matlab/engine/matlabengine.py", line 71, in __call__
_stderr, feval=True).result()
File "/opt/miniconda3/envs/py27/lib/python2.7/site-packages/matlab/engine/futureresult.py", line 67, in result
return self.__future.result(timeout)
File "/opt/miniconda3/envs/py27/lib/python2.7/site-packages/matlab/engine/fevalfuture.py", line 82, in result
self._result = pythonengine.getFEvalResult(self._future,self._nargout, None, out=self._out, err=self._err)
matlab.engine.EngineError: MATLAB function cannot be evaluated
Can anybody help me?

답변 (1개)

Ninad
Ninad 2023년 8월 29일
The provided error message indicates an issue with evaluating a MATLAB function in your Python script, but it doesn't directly imply a memory problem. To resolve this, follow these steps:
  1. Check MATLAB Compatibility: Ensure compatibility between the MATLAB version used to build the Docker image (Rr2021a) and the MATLAB engine in your Python environment (2.7). Confirm their compatibility and support.
  2. Verify MATLAB Function: Ensure accessibility and correct definition of the MATLAB function (`getFeatures_MT`) in the `importlib.m` script. Double-check the function name, inputs, and outputs.
  3. Debug Memory Issue: If you suspect memory shortage, try these approaches:
  • Optimize Memory Usage: Review code and MATLAB functions for memory-intensive operations. Reduce unnecessary data storage and use more memory-efficient structures.
  • Increase Docker Memory Limit: If the container has a memory limit, raise it using the `--memory` flag when starting the container.
  • Split Processing into Batches: If possible, divide the processing into smaller batches to reduce memory usage. Process each batch separately, freeing up memory in between.
  • Use a Machine with More Memory: Consider running the Docker image on a machine with higher memory capacity.
Additional Troubleshooting: If the issue persists, please provide more details about the MATLAB function and `importlib.m`. Check for other error messages or logs for further insights.

카테고리

Help CenterFile Exchange에서 Python Package Integration에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by