starting docker mathworks/matlab:r2023b from Python fails with licensing issue while running matlab from the docker's shell runs well

30 次查看(过去 30 天)
I am using docker built from mathworks/matlab:r2023b and am running the following Python code to start the engine.
self.matlab_engine: MatlabEngine = matlab.engine.start_matlab()
This fails to start Matlab with error:
matlab.engine.EngineError: Unable to launch MVM server: License Error: Licensing shutdown
.
self.matlab_engine: MatlabEngine = matlab.engine.start_matlab()
File "/usr/local/lib/python3.10/dist-packages/matlab/engine/__init__.py", line 128, in start_matlab
eng = future.result()
File "/usr/local/lib/python3.10/dist-packages/matlab/engine/futureresult.py", line 67, in result
return self.__future.result(timeout)
File "/usr/local/lib/python3.10/dist-packages/matlab/engine/matlabfuture.py", line 87, in result
handle = pythonengine.getMATLAB(self._future)
matlab.engine.EngineError: Unable to launch MVM server: License Error: Licensing shutdown
env. variable is set during docker run with
-e MLM_LICENSE_FILE=1234@lic_server.abc.company.com
If I run Matlab directly from the command line is works fine.
Any idea what is missing in my enviironment?

回答(2 个)

Prabhakar
Prabhakar 2023-10-13
Hi Shlomi
I suspect that the environment variable "MLM_LICENSE_FILE" is not being honored in the mathworks/matlab:r2023b container due to the presence of this file /opt/matlab/R2023b/licenses/license_info.xml
This is a known issue, and we are actively working towards releasing a newer version of the container image which should fix it for you.
In the mean time, could you try the following to work around the issue:
MatlabEngine = matlab.engine.start_matlab('-licmode file')
  3 个评论
Prabhakar
Prabhakar 2023-12-11
The mathworks/matlab:r2023b containers have already been updated on DockerHub to include the fix to this issue.
Shown below are the steps I took to verify that this works now:
$ docker run -it --rm -e MLM_LICENSE_FILE=1234@lic_server.abc.company.com --entrypoint /bin/bash mathworks/matlab:r2023b
matlab@0e3b71b68603:~/Documents/MATLAB$ export LD_LIBRARY_PATH=/opt/matlab/R2023b/bin/glnxa64
matlab@0e3b71b68603:~/Documents/MATLAB$ python -m pip install matlabengine
Defaulting to user installation because normal site-packages is not writeable
Collecting matlabengine
Downloading matlabengine-23.2.1.tar.gz (18 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: matlabengine
Building wheel for matlabengine (pyproject.toml) ... done
Created wheel for matlabengine: filename=matlabengine-23.2.1-py3-none-any.whl size=16895 sha256=6759b5317c2da7fc8e6c65124849bdaeda3b1ac7c0e046585b7866c5bb5410e3
Stored in directory: /home/matlab/.cache/pip/wheels/a8/33/f3/84a8299d4675c04ea1a01073f8e347e6c8498ad8789201e220
Successfully built matlabengine
Installing collected packages: matlabengine
Successfully installed matlabengine-23.2.1
matlab@0e3b71b68603:~/Documents/MATLAB$ python
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matlab.engine
>>> eng = matlab.engine.start_matlab()
>>> eng.sqrt(4.0)
2.0
>>>

请先登录,再进行评论。


Prabhakar
Prabhakar 2023-12-11
mathworks/matlab:r2023b has been updated to include the fix to this issue.
Verify it by:
Pulling the latest image from dockerhub:
docker pull mathworks/matlab:r2023b
Run container with MLM_LICENSE_FILE specified, and run MATLAB Engine for Python:
$ docker run -it --rm -e MLM_LICENSE_FILE=1234@lic_server.abc.company.com --entrypoint /bin/bash mathworks/matlab:r2023b
matlab@0e3b71b68603:~/Documents/MATLAB$ export LD_LIBRARY_PATH=/opt/matlab/R2023b/bin/glnxa64
matlab@0e3b71b68603:~/Documents/MATLAB$ python -m pip install matlabengine
Defaulting to user installation because normal site-packages is not writeable
Collecting matlabengine
Downloading matlabengine-23.2.1.tar.gz (18 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: matlabengine
Building wheel for matlabengine (pyproject.toml) ... done
Created wheel for matlabengine: filename=matlabengine-23.2.1-py3-none-any.whl size=16895 sha256=6759b5317c2da7fc8e6c65124849bdaeda3b1ac7c0e046585b7866c5bb5410e3
Stored in directory: /home/matlab/.cache/pip/wheels/a8/33/f3/84a8299d4675c04ea1a01073f8e347e6c8498ad8789201e220
Successfully built matlabengine
Installing collected packages: matlabengine
Successfully installed matlabengine-23.2.1
matlab@0e3b71b68603:~/Documents/MATLAB$ python
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matlab.engine
>>> eng = matlab.engine.start_matlab()
>>> eng.sqrt(4.0)
2.0
>>>

类别

Help CenterFile Exchange 中查找有关 Python Package Integration 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by