如何使外部工具箱可供 MATLAB 并行计算工具箱作业使用?
As a continuation of this question and the subsequent answer, does anyone know how to have a job created using the Parallel Computing Toolbox (using createJob
and createTask
) access external toolboxes? Is there a configuration parameter I can specify when creating the function to specify toolboxes that should be loaded?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据文档的这一部分,您可以执行此操作的方法是指定
'PathDependency'
属性 或'FileDependency'
属性作业对象的 ,以便它指向您需要作业工作人员能够使用的功能。您应该能够在
KbCheck
函数 中指出方向="http://psychtoolbox.org/wikka.php?wakka=HomePage" rel="nofollow">PsychToolbox,以及KbCheck
正常工作所需的任何其他函数或目录。它看起来像这样:According to this section of the documentation, one way you can do this is to specify either the
'PathDependencies'
property or the'FileDependencies'
property of the job object so that it points to the functions you need the job's workers to be able to use.You should be able to point the way to the
KbCheck
function in PsychToolbox, along with any other functions or directories needed forKbCheck
to work properly. It would look something like this:根据我的故障排除工作,有几点评论:
嵌套函数和匿名函数与并行计算工具包的配合程度似乎不一致。我无法让它们工作,而其他有能够。 (另请参阅此处。)因此,我建议每个函数存储在它自己的文件中,并使用
PathDependency< 包含这些文件/code>
或
FileDependency
属性,如上面 gnovice 所描述的。对并行计算工具包进行故障排除非常困难,因为一切都发生在您的视野之外。在代码中自由使用断点,
inspect
命令是您的朋友。另请注意,如果出现错误,任务对象将包含一个错误参数,该参数又将包含ErrorMessage
字符串,并且可能包含Error.causes
MException 对象。这两者在调试中都非常有用。当包含 Psychtoolbox 时,您需要按如下方式进行。首先,创建一个
jobStartup.m
文件包含以下几行:但是,由于并行计算工具包无法处理任何图形功能,因此按原样运行
SetupPsychtoolbox
实际上会导致线程崩溃。为了避免这种情况,您需要编辑PsychtoolboxPostInstallRoutine
函数,该函数在SetupPsychtoolbox
的最后调用。具体来说,您需要注释掉AssertOpenGL
行(第 496 行,截至本答案时;这可能在未来版本中发生变化)。A few comments, based on my work troubleshooting this:
It appears that there are inconsistencies with how well nested functions and anonymous functions work with the Parallel Computation toolkit. I was unable to get them to work, while others have been able to. (Also see here.) As such, I would recommend having each function stored in it's own file, and including those files using the
PathDependencies
orFileDependencies
properties, as described by gnovice above.It is very hard to troubleshoot the Parallel Computation toolkit, as everything happens outside your view. Use breakpoints liberally in your code, and the
inspect
command is your friend. Also note that if there is an error, task objects will contain an error parameter, which in turn will containErrorMessage
string, and possibly theError.causes
MException object. Both of these were immensely useful in debugging.When including Psychtoolbox, you need to do it as follows. First, create a
jobStartup.m
file with the following lines:However, since the Parallel Computation toolkit can't handle any graphics functionality, running
SetupPsychtoolbox
as-is will actually cause your thread to crash. To avoid this, you need to edit thePsychtoolboxPostInstallRoutine
function, which is called at the very end ofSetupPsychtoolbox
. Specifically, you want to comment out the lineAssertOpenGL
(line 496, as of the time of this answer; this may change in future releases).