1
votes

I just encountered and circumvented a problem in Matlab, but I'm still wondering why this happens, and I also want to leave the information here for future reference.

In Matlab's Parallel Computing Toolbox, the command matlabpool local starts a local pool of Matlab workers which are then used transparently to speed up commands like parfor by distributing processing onto the different CPU cores. I tried to do so on a Linux machine which I connected to through ssh from my home Linux computer. I used ssh without X forwarding because the script I wanted to run only computes and saves the result, but does not produce graphical output.

The problem: matlabpool hung forever, without any indication of the cause. I restarted the remote machine, restarted Matlab, checked for license problems, without result.

The problem was resolved however when I closed ssh and logged back in, this time including the -X option for X11 forwarding – even though then I started Matlab with the -nodesktop option.

Does anyone have an idea why matlabpool on Linux appears to depend on access to X11?

1
This is definitely not expected. I just tried here using R2014a on GLNXA64 machine and was able to launch a matlabpool (or parpool as it's now called) successfully. What version of MATLAB are you using? - Edric
@Edric, my version is 2013a. I'll try and see whether I can get an update. - A. Donda
Very strange - I just tried R2013a and everything worked for me. - Edric

1 Answers

0
votes

Even though matlabpool starts and communicates with background headless workers, you can still create figures and plots and print/export them as images inside the parfor parallel loop. The following is a valid use case:

matlabpool(..)
parfor i=1:4
    plot(..)
    print(...)
    close(..)
end

To me this suggests that background workers will still depend on graphics capabilities to generate the invisible plots in memory (maybe it's using virtual framebuffers and such). Of course this is just speculation on my part :)


EDIT:

Just to be sure here, can you try the following sequence of commands:

[client]$ ssh -v -x user@server    # X11 forwarding disabled

[server]$ unset DISPLAY            # clear $DISPLAY variable
[server]$ nohup matlab -nodesktop -nodisplay -noFigureWindows -nosplash \
                       -r "myscript; quit;" 2>&1 < /dev/null &

Where the script contains a simple parallel test like:

myscript.m

parpool('local',2)
smpd
    fprintf('hello from lab#%d', labindex);
end
delete(gcp('nocreate'))

If MATLAB still hangs, try adding the -debug start option:

matlab -debug starts MATLAB and displays debugging information that can be useful, especially for X based problems.