How to call MATLAB executable for Python on cluster?

老子叫甜甜 提交于 2019-12-06 15:55:08
user3666197

Step 0:

Check whether the code-segment responsible for "remote" launch of MATLAB goes well - for details about params, check pymatbridge.py:

    ### class _Session( object ): _____________________________
    ...

    def _run_server(self):
        code = self._preamble_code()
        code.extend([
            "matlabserver('%s')" % self.socket_addr
        ])
        command = '%s %s %s "%s"' % ( self.executable,
                                      self.startup_options,
                                      self._execute_flag(),
                                      ','.join( code )
                                      )
        subprocess.Popen( command,
                          shell  = True,
                          stdin  = subprocess.PIPE,
                          stdout = subprocess.PIPE
                          )

If such invocation works on any Cluster-Node you will try to harness in a massively distributed MATLAB scenario, the problem goes into ZeroMQ messaging part, if not, the remote server simply cannot launch a _Session, while the messaging ( and all it's { ipc:// | tcp:// | pgm:// | epgm:// | vmci:// } transport-classes available for a massively-distributed computing ) is not to be blamed.

Step 1:

If Step 0 ( a subprocess.Popen(...) invocation ) works well on all remote nodes, check all the ZeroMQ / pymatbridge pre-requisites ( dynamic loader settings - lines added to all remote cluster nodes' .bash_profile ( or similar file for respective shell ).

Yes, a tedious task to prove all remote nodes on the cluster meet these, but without checking these, there is no warranty a remote node can operate the remote MATLAB process connected via otherwise smart and powerful tool, like the pymatbridge is.

In the end I found a method that works that is very simple. In the .pbs script I load the MATLAB module using

module load matlab/2015a

Then in the Python script the command

mlab = Matlab()

automatically detects the correct MATLAB path. I thus do not need to specify the path using the optional executable argument.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!