如何使外部工具箱可供 MATLAB 并行计算工具箱作业使用?

发布于 2024-10-07 10:07:06 字数 337 浏览 4 评论 0原文

作为问题和后续答案,有谁知道如何使用并行计算工具箱创建作业(使用 < code>createJob 和 createTask)访问外部工具箱?创建函数时是否可以指定配置参数来指定应加载的工具箱?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

囚你心 2024-10-14 10:07:06

根据文档的这一部分,您可以执行此操作的方法是指定 'PathDependency' 属性'FileDependency' 属性作业对象的 ,以便它指向您需要作业工作人员能够使用的功能。

您应该能够在 KbCheck 函数 中指出方向="http://psychtoolbox.org/wikka.php?wakka=HomePage" rel="nofollow">PsychToolbox,以及 KbCheck 正常工作所需的任何其他函数或目录。它看起来像这样:

obj = createJob('PathDependencies',{'path_to_KbCheck',...
                                    'path_to_other_PTB_functions'});

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 for KbCheck to work properly. It would look something like this:

obj = createJob('PathDependencies',{'path_to_KbCheck',...
                                    'path_to_other_PTB_functions'});
节枝 2024-10-14 10:07:06

根据我的故障排除工作,有几点评论:

  • 嵌套函数和匿名函数与并行计算工具包的配合程度似乎不一致。我无法让它们工作,而其他有能够。 (另请参阅此处。)因此,我建议每个函数存储在它自己的文件中,并使用 PathDependency< 包含这些文件/code>FileDependency 属性,如上面 gnovice 所描述的。

  • 对并行计算工具包进行故障排除非常困难,因为一切都发生在您的视野之外。在代码中自由使用断点,inspect 命令是您的朋友。另请注意,如果出现错误,任务对象将包含一个错误参数,该参数又将包含 ErrorMessage 字符串,并且可能包含 Error.causes MException 对象。这两者在调试中都非常有用。

  • 当包含 Psychtoolbox 时,您需要按如下方式进行。首先,创建一个 jobStartup.m文件包含以下几行:

    PTB_path = '/Users/eliezerk/Documents/MATLAB/Psychtoolbox3/';
    添加路径(PTB_path);
    cd(PTB_路径);
    设置Psychtoolbox;
    

    但是,由于并行计算工具包无法处理任何图形功能,因此按原样运行 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 or FileDependencies 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 contain ErrorMessage string, and possibly the Error.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:

    PTB_path = '/Users/eliezerk/Documents/MATLAB/Psychtoolbox3/';
    addpath( PTB_path );
    cd( PTB_path );
    SetupPsychtoolbox;
    

    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 the PsychtoolboxPostInstallRoutine function, which is called at the very end of SetupPsychtoolbox. Specifically, you want to comment out the line AssertOpenGL (line 496, as of the time of this answer; this may change in future releases).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文