MPh-py / MPh

Pythonic scripting interface for Comsol Multiphysics
https://mph.readthedocs.io
MIT License
265 stars 67 forks source link

License Error When mph.start() Called on HPC Compute Node #148

Closed Alex-Meek closed 1 year ago

Alex-Meek commented 1 year ago

Hello,

I'm having an issue when calling mph.start(), but only when the function is called on a HPC compute node (works fine on the login node, and on other work stations like my laptop / remote servers).

For example, in the login node (or any other work station), I can activate my conda environment with mph installed, navigate to the mph installation. Then, run python test_session.py, which results in no output.

However, if I do the same on a compute node, I receive the following error:

java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.comsol.webbridge.Web$1.run(SourceFile:568)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
        at com.comsol.bridge.session.f.closeSession(SourceFile:255)
        at com.comsol.bridge.Bridge.closeSession(SourceFile:698)
        ... 6 more
Traceback (most recent call last):
  File "Thread.java", line 748, in java.lang.Thread.run
Exception: Java Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/users/USERNAME/Repositories/CustomPythonPackages/mphCustom/tests/test_session.py", line 32, in <module>
    test_start()
  File "/users/USERNAME/Repositories/CustomPythonPackages/mphCustom/tests/test_session.py", line 21, in test_start
    client = mph.start(cores=1)
             ^^^^^^^^^^^^^^^^^^
  File "/users/USERNAME/Repositories/CustomPythonPackages/mphCustom/mph/session.py", line 104, in start
    client = Client(cores=cores, version=version, port=server.port)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/users/USERNAME/Repositories/CustomPythonPackages/mphCustom/mph/client.py", line 244, in __init__
    self.connect(port, host)
  File "/users/USERNAME/Repositories/CustomPythonPackages/mphCustom/mph/client.py", line 427, in connect
    self.java.connect(host, port)
com.comsol.util.exceptions.com.comsol.util.exceptions.LicenseException: Exception:
        com.comsol.util.exceptions.LicenseException: License error
Messages:
        License error.

I should add that I have my own version of the mph package in which I manually set the jvm.dll/.so path in discovery.py for my older COMSOL 5.4 version, but other than that the package is identical. Further, I've validated that mph is working correctly on other machines regardless; I can start clients, create, run, and evaluate models as expected.

Any knowledge with regards to why this is happening would be appreciated, as I'm not familiar with java. Thanks!

john-hen commented 1 year ago

This would happen because your compute node can't reach the Comsol license manager, I would think.

Alex-Meek commented 1 year ago

I've diagnosed the issue with a colleague and the issue seems to be related to MPI/COMSOL on the cluster. Running on a node without MPI solves the issue. This isn't an issue with Mph so I'll close this, thanks.