本文介绍了如何在群集上为Python调用MATLAB可执行文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用,它通过以下方式从python调用MATLAB在ZMQ套接字上启动它。在我自己的计算机上,我将可执行文件的位置(在本例中为MATLAB 2014B)传递给了桥梁:

I am using a python-matlab-bridge that calls MATLAB from python by starting it on a ZMQ socket. On my own computer, I hand the bridge the location of the executable (in this case MATLAB 2014B):

executable='/Applications/MATLAB_R2014b.app/bin/matlab'

,所有内容均按要求工作,打印的声明为:

and everything works as required and the printed statement is:

Starting MATLAB on ZMQ socket ipc:///tmp/pymatbridge-49ce56ed-f5b4-43c4-8d53-8ae0cd30136d

现在我想在群集上执行相同的操作。通过模块可用,我发现有两个可用的MATLAB版本(2015a和2016b),它们位于以下路径:

Now I want to do the same on a cluster. Through module avail I find there are two MATLAB versions (2015a and 2016b) available and located at the following path:

/opt/ud/LOCAL/etc/modulefiles/matlab.

当我现在使用以下方式调用MATLAB时:

When I now call MATLAB using:

executable='/opt/ud/LOCAL/etc/modulefiles/matlab/MATLAB_R2015a.app/bin/matlab'

错误:

 Starting MATLAB on ZMQ socket ipc:///tmp/pymatbridge-95775445-359d-441f-803a-7193eedbf215
Send 'exit' command to kill the server
............................................................MATLAB session timed out after 60 seconds

已返回。它找不到MATLAB可执行文件。

is returned. It cannot find the MATLAB executable. How to proceed?

推荐答案

最后,我发现了一种非常简单的方法。在.pbs脚本中,我使用

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

然后在Python脚本中输入命令

Then in the Python script the command

mlab = Matlab()

自动检测正确的MATLAB路径。因此,我不需要使用可选的 executable 参数指定路径。

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

这篇关于如何在群集上为Python调用MATLAB可执行文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 04:42