ECPS COMPUTING CLUSTER
ECPS cluster : matlab
français | english
Navigation
Ce wiki
Cette page

Matlab on Your Workstation

Mac OS X

  1. Download and install Matlab from Distrilog
  2. Install XCode
  3. Open a Terminal, type the following command followed by Return:
    /Applications/MATLAB*.app/bin/mex -setup
    Ensure that that command completes successfuly. If not, send an email to imt-it@groupes.epfl.ch with a screen capture of the result.

Use the ECPS cluster with Matlab

 

Prerequisites

  1. you need to have password-less shell access going. See the Getting Started guide on the wiki homepage.
  2. through said shell access, you need to be able to run a simple command, like
    salloc echo SUCCESS
    This should output SUCCESS (among other things) to your terminal.
  3. you want to be familiar with copying files back and forth between your computer and the ECPS cluster

Your First Batch Job

  1. Browse the directory /usr/local/matlab/epfl-batch on ECPS, and download the appropriate ZIP file for your Matlab version (for instance epfl.remote.r2017a.zip)
  2. Unpack that ZIP file somewhere in your Matlab path (for instance on Mac, into Documents/MATLAB )
  3. Type
    configCluster
    and answer the question regarding your username on ECPS (it's your GASPAR username)

     
  4. Create a file parallel_hostnames.m in your PATH (for instance on a Mac, in Documents/MATLAB) with the following contents:
    spmd
        !hostname
    end
    
  5. Type the following commands:
    c = parcluster;
    j = c.batch('parallel_hostnames', 'Pool', 40, 'CurrentFolder', '.');
  6. When prompted whether to use an identity file, click Yes
  7. Now comes the tricky part. The file you want is in the .ssh subdirectory of your home directory, which is hidden since its name starts with a dot. Press ⌘+⇧+G to open the "go to the folder"  prompt, and type  ~/.ssh (tilde slash dot ssh) into the dialog.
  8. Pick the id_rsa file (this is your private key), and click Open
  9. You should now be able to see your job in progress. In Matlab's tool ribbon, click → Monitor Jobs. Be sure that the ECPS remote profile is selected, then click on the button, you should get something like this:

    Keep clicking on until the job transitions into "finished" state.
    💡If this doesn't work, see the troubleshooting § in the admin guide.
  10. To get the results of your finished job, right-click on its entry and select Show diary

    You can see that different instances ran on different nodes on the cluster, courtesy of SLURM.

    💡You can also browse the job queue by typing
    c.Jobs
    If you are running a graphical Matlab, you can then click your way to the job details directly from the command window.
  11. This job doesn't compute anything; it only has side effects. If you now want to follow the Mathworks tutorial and create a job that does return something, here is how to fetch the return value:
    j.fetchOutputs{:}

Congratulations for coming so far! If you want to know more, and in particular:

  • running jobs that last more than 15 minutes,
  • getting job completion notifications over email,

then please continue reading the complete instructions from MathWorks.

Toolboxes

Tips and Tricks

Get an email after a batch job completes

ClusterInfo.setEmailAddress('my.address@epfl.ch')

Advanced Topics

Behind the Scenes: Matlab Parallel Computing in ECPS

All you always wanted to know about MDCE

About Copying Your Source Files

Whenever you submit a batch job from your workstation, at the beginning of the so-called "mirroring" procedure described in the MDCE documentation, Matlab tries to figure out which files will be required, despite not being in the current directory, and copies them over into ECPS.

However, this mechanism relies on static analysis of your code and is not fool-proof. To work around its limitations should you encounter them, you might want to set up a subdirectory in your home directory on ECPS, set the 'CurrentFolder' to it in the call to c.batch and copy your files to it using FileZilla or Cyberduck.

If you use this mechanism, you need to understand that Matlab will not be syncing these files for you. You therefore have two options:

  • Use 'CurrentFolder' and clearly distinguish in your head which files Matlab takes care of, and which ones you need to keep syncing onto the cluster by hand;
  • Or cross the chasm — Keep and edit both your code and data on ECPS, and run the batch jobs directly from inside the cluster (next section).

Running Batch Jobs from the Command Line

In case you are away with poor network connectivity precluding the use of the regular Matlab client + VPN; or if you have mastered the UNIX command line enough that you only use that anymore:

  1. ssh to one of the nodes
  2. Create a parallel_hostnames.m test file into your home directory on ECPS, with the same contents as in the workstation use-case:
    spmd
        !hostname
    end
    
  3. Run
    module load matlab
    matlab -nodisplay
  4. Go through the cluster configuration procedure again (configCluster etc.)

    💡 You don't need an SSH key this time, and you can type any (non-empty) string as the password; it will be ignored.
  5. Run the test batch job again: at the Matlab prompt type
        c = parcluster;
    
        j = c.batch('parallel_hostnames', 'Pool', 40, 'CurrentFolder', '.');
      
Rechercher
Partager