How can I make an external toolbox available to a MATLAB Parallel Computing Toolbox job?

前端 未结 2 1402
闹比i
闹比i 2021-01-21 14:29

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 <

相关标签:
2条回答
  • 2021-01-21 14:55

    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'});
    
    0 讨论(0)
  • 2021-01-21 15:06

    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).

    0 讨论(0)
提交回复
热议问题