mathworks-ref-arch / matlab-dockerfile

Create a docker container that contains a MATLAB install
Other
345 stars 96 forks source link

Gitlab-CI: Matlab asks for license credentials since 2023b although the container was called like the one for 2023a #76

Closed GenosseFlosse closed 1 year ago

GenosseFlosse commented 1 year ago

Hey there!

I am using matlab containers as described in building-on-matlab-docker-image.

My Gitlab-CI calls:

.test-image:
  stage: test
  tags:
    - docker
  variables:
    VER: r2023b # is overridden in job call to test multiple matlab versions (2020b, 23a, 23b, latest)
    CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:test_$VER
    CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:$VER
  image: 
    name: $CONTAINER_TEST_IMAGE
    entrypoint: [""]
  script:
    - matlab -batch test
    - test -e testres.mat
  artifacts:
    paths:
      - testres.mat

Curiously, until 2023a, everything is working okay. But using 2023b, matlab does not use the network license I provide but instead asks me to put in an E-Mail address. To further debug the issue I ran the container for 2023b on Docker Desktop:

docker run gitlab.example.com/docker/docker_matlab_gurobi:test_latest matlab -batch rand
Please enter your MathWorks Account email address and press Enter:
Sign-in failed. Would you like to retry? y/n [n]

This is the same behaviour I encounter in Gitlab CI

Running the container for 2023a on Docker Desktop:

docker run  gitlab.example.com/docker/docker_matlab_gurobi:test_r2023a matlab -batch rand
ans =

    0.8147

This is also the same behaviour I encounter for 2023a in the Gitlab CI.

So here is what I don't understand: Why does one container work and the other doesn't although everything is configured the same and called the same? Did something change in the default entrypoint?

prabhakk-mw commented 1 year ago

Are you sure the licence file that is being used by the network manager is updated for use with 2023b?

What's the result of running the following command:

docker run --init --rm -e MLM_LICENSE_FILE=27000@MyServerName mathworks/matlab:r2023b -batch ver

prabhakk-mw commented 1 year ago

Thank you @GenosseFlosse for that information! We will dig deeper, and get back to you.

GenosseFlosse commented 1 year ago

Hey, thanks for taking the time :) The Result is the following (I Xed out our license server):

Licensing MATLAB using the license manager XXXXX@licenseXXXXX.XXXXXX.de.
Running matlab -licmode file -batch  "ver"
-----------------------------------------------------------------------------------------------------
MATLAB Version: 23.2.0.2365128 (R2023b)
MATLAB License Number: XXXXXX
Operating System: Linux 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
-----------------------------------------------------------------------------------------------------
MATLAB                                                Version 23.2        (R2023b)

Addition: Yeah, we use the same network license for our desktop MATLAB versions. They work fine! Addition: Deleted old comment: License number was visible

GenosseFlosse commented 1 year ago

The same issue seems to be present on the official docker containers of mathworks. Calling matlab -batch ver:

C:\Users\GenosseFlosse>docker run --init --rm -e MLM_LICENSE_FILE=XXXXX@licenseXXXXX.XXXXXX.de mathworks/matlab:r2023a matlab -batch ver
-----------------------------------------------------------------------------------------------------
MATLAB Version: 9.14.0.2337262 (R2023a) Update 5
MATLAB License Number: XXXXXX
Operating System: Linux 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
-----------------------------------------------------------------------------------------------------
MATLAB                                                Version 9.14        (R2023a)

C:\Users\GenosseFlosse>docker run --init --rm -e MLM_LICENSE_FILE=XXXXX@licenseXXXXX.XXXXXX.de mathworks/matlab:r2023b matlab -batch ver
Please enter your MathWorks Account email address and press Enter:
Sign-in failed. Would you like to retry? y/n [n]

C:\Users\GenosseFlosse>

So calling matlab -batch ver instead of just -batch ver seems to result in matlab ignoring the MLM_LICENSE_FILE in 2023b.

Here the log when just calling -batch ver (everything works):

C:\Users\GenosseFlosse>docker run --init --rm -e MLM_LICENSE_FILE=XXXXX@licenseXXXXX.XXXXXX.de mathworks/matlab:r2023b -batch ver
Licensing MATLAB using the license manager XXXXX@licenseXXXXX.XXXXXX.de.
Running matlab -licmode file -batch  "ver"
-----------------------------------------------------------------------------------------------------
MATLAB Version: 23.2.0.2365128 (R2023b)
MATLAB License Number: XXXXXX
Operating System: Linux 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
-----------------------------------------------------------------------------------------------------
MATLAB                                                Version 23.2        (R2023b)

C:\Users\GenosseFlosse>docker run --init --rm -e MLM_LICENSE_FILE=XXXXX@licenseXXXXX.XXXXXX.de mathworks/matlab:r2023a -batch ver
Licensing MATLAB using the license manager XXXXX@licenseXXXXX.XXXXXX.de.
Running matlab -batch  "ver"
-----------------------------------------------------------------------------------------------------
MATLAB Version: 9.14.0.2337262 (R2023a) Update 5
MATLAB License Number: XXXXXX
Operating System: Linux 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
-----------------------------------------------------------------------------------------------------
MATLAB                                                Version 9.14        (R2023a)

C:\Users\GenosseFlosse>

It should be possible to call matlab -batch someScript since in the example CI config for matlab on gitlab this is the case. And the behaviour of the container should be consistent throughout releases for us (customers) to be able to test against new releases easily. Thank you for being lightning fast in your response here on GH!

philipc-mw commented 1 year ago

Hi @GenosseFlosse , thank you for the info and the quick responses :+1:

I am glad to hear that everything works when just calling -batch ver, without the matlab - can I confirm that you now have a solution that works for you across the range of releases you wish to test? Please let us know if you have any further issues.

GenosseFlosse commented 1 year ago

The issue is still present and I do not consider it solved. I would like to explain, why: As you can see, I call matlab explicitly inside the container and explicitly test for the presence of my test result after matlab exited.

  script:
    - matlab -batch test
    - test -e testres.mat

This is no longer possible since r2023b and I wish it to be possible. Using

  script:
    - -batch test
    - test -e testres.mat

gives the following gitlab error:

$ -batch test
/usr/bin/bash: line 133: -batch: command not found
prabhakk-mw commented 1 year ago

Is it an acceptable solution to update the script command to:

 script:
    - matlab -licmode file -batch test
    - test -e testres.mat

This change should work with all releases of MATLAB in your test matrix...

GenosseFlosse commented 1 year ago

Yes that worked! Thank you!

Still the example gitlab CI with matlab needs an update then...

prabhakk-mw commented 1 year ago

I'm glad that worked! We will notify the teams that own the gitlab CI templates about this issue, and also remember to consider this workflow for future versions of mathworks/matlab containers.

Thank you for reporting the issue, and please let us know if we can be of any further assistance!