MATLAB
From FarmShare
Line 38: | Line 38: | ||
You should get output file like matlab_example.oXXXXX | You should get output file like matlab_example.oXXXXX | ||
+ | <pre>Warning: No display specified. You will not be able to display graphics on the screen. | ||
+ | Warning: No window system found. Java option 'MWT' ignored | ||
+ | |||
+ | < M A T L A B (R) > | ||
+ | Copyright 1984-2011 The MathWorks, Inc. | ||
+ | R2011b (7.13.0.564) 64-bit (glnxa64) | ||
+ | August 13, 2011 | ||
+ | |||
+ | |||
+ | To get started, type one of these: helpwin, helpdesk, or demo. | ||
+ | For product information, visit www.mathworks.com. | ||
+ | |||
+ | >> Hello World | ||
+ | </pre> | ||
+ | |||
+ | = example second matlab file run via qsub = | ||
+ | |||
+ | Now we want to make sure we avoid AFS. | ||
+ | |||
+ | Here's our helloworld.m: | ||
+ | <source lang="m">disp('Hello World'); | ||
+ | </source> | ||
+ | Here's a command to run that non-interactively: | ||
+ | |||
+ | matlab -nodesktop < helloworld.m | ||
+ | |||
+ | We want to run this same command via the job scheduling system. Let's write a job script. | ||
+ | <source lang="sh"> | ||
+ | #!/bin/bash | ||
+ | |||
+ | #$ -N matlab_example | ||
+ | #$ -m bes | ||
+ | #$ -M chekh@stanford.edu | ||
+ | #$ -V | ||
+ | |||
+ | matlab -nodesktop < /mnt/glusterfs/chekh/helloworld.m | ||
+ | </source> | ||
+ | |||
+ | Submit the script: | ||
+ | |||
+ | cd /mnt/glusterfs/chekh | ||
+ | qsub -cwd matlab_example.script | ||
+ | |||
+ | Look at the job status: | ||
+ | |||
+ | qstat | ||
+ | |||
+ | You should get output file like matlab_example.oXXXXX in your current directory | ||
<pre>Warning: No display specified. You will not be able to display graphics on the screen. | <pre>Warning: No display specified. You will not be able to display graphics on the screen. | ||
Warning: No window system found. Java option 'MWT' ignored | Warning: No window system found. Java option 'MWT' ignored |
Revision as of 14:22, 26 February 2013
Contents |
first steps
Per FarmShare software try something like:
module avail module load MATLAB-R2012b
If you're running MATLAB for the first time, it'll try to write some stuff into $HOME/.matlab so make sure you have your AFS tokens or else MATLAB will crash with an undecipherable error message.
example single matlab file run via qsub
Here's our helloworld.m:
disp('Hello World');
Here's a command to run that non-interactively:
matlab -nodesktop < helloworld.m
We want to run this same command via the job scheduling system. Let's write a job script.
#!/bin/bash #$ -N matlab_example #$ -m bes #$ -M chekh@stanford.edu #$ -V matlab -nodesktop < /mnt/glusterfs/chekh/helloworld.m
Submit the script:
qsub matlab_example.script
Look at the job status:
qstat
You should get output file like matlab_example.oXXXXX
Warning: No display specified. You will not be able to display graphics on the screen. Warning: No window system found. Java option 'MWT' ignored < M A T L A B (R) > Copyright 1984-2011 The MathWorks, Inc. R2011b (7.13.0.564) 64-bit (glnxa64) August 13, 2011 To get started, type one of these: helpwin, helpdesk, or demo. For product information, visit www.mathworks.com. >> Hello World
example second matlab file run via qsub
Now we want to make sure we avoid AFS.
Here's our helloworld.m:
disp('Hello World');
Here's a command to run that non-interactively:
matlab -nodesktop < helloworld.m
We want to run this same command via the job scheduling system. Let's write a job script.
#!/bin/bash #$ -N matlab_example #$ -m bes #$ -M chekh@stanford.edu #$ -V matlab -nodesktop < /mnt/glusterfs/chekh/helloworld.m
Submit the script:
cd /mnt/glusterfs/chekh qsub -cwd matlab_example.script
Look at the job status:
qstat
You should get output file like matlab_example.oXXXXX in your current directory
Warning: No display specified. You will not be able to display graphics on the screen. Warning: No window system found. Java option 'MWT' ignored < M A T L A B (R) > Copyright 1984-2011 The MathWorks, Inc. R2011b (7.13.0.564) 64-bit (glnxa64) August 13, 2011 To get started, type one of these: helpwin, helpdesk, or demo. For product information, visit www.mathworks.com. >> Hello World
PCT
We have the Parallel Computing Toolbox, you can use that to parallelize your job across multiple cores in a single machine.
Here's how to write a job using MDCS: http://docs.uabgrid.uab.edu/wiki/MatLab_CLI#Parallel_MATLAB
You can use the "maxNumCompThreads" command (deprecated) to see how many parallel threads you can run. I get "24" on barley, or "8" on corn.
simple PCT run
matlab -nodesktop -r 'maxNumCompThreads' >> matlabpool ( 'open', 'local', 8) Starting matlabpool using the 'local' configuration ... connected to 8 labs. >> >> matlabpool size ans = 8 Then use 'parfor' instead of 'for'.
matlabpool of size 0 and size 1 are effectively the same, except the latter uses a PCT toolbox license.
Here are some training slides and example code that I copied from http://www.osc.edu/~samsi/sc11edu/
Search the farmshare-discuss archives for posts about Matlab.