MATLAB
From FarmShare
Line 1: | Line 1: | ||
- | We don't have a license for MATLAB Distributed Compute Server (MDCS aka MDCE). | + | We don't have a license for MATLAB Distributed Compute Server (MDCS aka MDCE). |
- | We do have the Parallel Computing Toolbox, you can use that to parallelize your job across multiple cores in a single machine. | + | We do 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 | + | 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. | + | 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== | + | == simple PCT run == |
- | <pre> | + | <pre>/afs/ir.stanford.edu/software/matlab-2011b/bin/matlab -nodesktop -r 'maxNumCompThreads' |
- | /afs/ir.stanford.edu/software/matlab-2011b/bin/matlab -nodesktop -r 'maxNumCompThreads' | + | |
- | + | >> matlabpool ( 'open', 'local', 8) | |
Starting matlabpool using the 'local' configuration ... connected to 8 labs. | Starting matlabpool using the 'local' configuration ... connected to 8 labs. | ||
- | + | >> | |
- | + | >> matlabpool size | |
ans = | ans = | ||
Line 21: | Line 20: | ||
Then use 'parfor' instead of 'for'. | Then use 'parfor' instead of 'for'. | ||
- | </pre> | + | </pre> |
+ | 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/ | |
- | + | *http://stanford.edu/~chekh/matlab.tar | |
- | * http://stanford.edu/~chekh/matlab.tar | + | |
- | ==example single matlab file run via qsub== | + | == example single matlab file run via qsub == |
- | Here's our helloworld.m: | + | Here's our helloworld.m: |
- | <pre> | + | <pre>disp('Hello World'); |
- | disp('Hello World'); | + | </pre> |
- | </pre> | + | Here's a command to run that. |
- | + | /afs/ir.stanford.edu/software/matlab-2011b/bin/matlab -nodesktop < helloworld.m | |
- | /afs/ir.stanford.edu/software/matlab-2011b/bin/matlab -nodesktop | + | |
- | We want to run this same command via the job scheduling system. Let's write a job script. | + | We want to run this same command via the job scheduling system. Let's write a job script. |
- | + | <pre>$ cat matlab_example.script | |
- | <pre> | + | |
- | $ cat matlab_example.script | + | |
#!/bin/bash | #!/bin/bash | ||
Line 48: | Line 44: | ||
#$ -M chekh@stanford.edu | #$ -M chekh@stanford.edu | ||
- | /afs/ir.stanford.edu/software/matlab-2011b/bin/matlab -nodesktop | + | /afs/ir.stanford.edu/software/matlab-2011b/bin/matlab -nodesktop < /afs/ir/users/c/h/chekh/helloworld.m |
- | </pre> | + | </pre> |
+ | Submit the script: | ||
- | |||
qsub matlab_example.script | qsub matlab_example.script | ||
- | Look at the job status: | + | Look at the job status: |
+ | |||
qstat | qstat | ||
- | You should get output file like matlab_example.oXXXXX | + | You should get output file like matlab_example.oXXXXX |
- | + | ||
<pre> | <pre> | ||
- | |||
Warning: No display specified. You will not be able to display graphics on the screen. | 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 | ||
- | + | < M A T L A B (R) > | |
Copyright 1984-2011 The MathWorks, Inc. | Copyright 1984-2011 The MathWorks, Inc. | ||
R2011b (7.13.0.564) 64-bit (glnxa64) | R2011b (7.13.0.564) 64-bit (glnxa64) | ||
Line 73: | Line 68: | ||
For product information, visit www.mathworks.com. | For product information, visit www.mathworks.com. | ||
- | + | >> Hello World | |
</pre> | </pre> | ||
+ | ---- | ||
+ | |||
+ | Search the farmshare-discuss archives for [https://mailman.stanford.edu/mailman/swish?query=Matlab&submit=Search+farmshare-discuss+%21&listname=farmshare-discuss&metaname=swishdefault&sort=unixdate Matlab]. |
Revision as of 12:09, 26 April 2012
We don't have a license for MATLAB Distributed Compute Server (MDCS aka MDCE).
We do 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
/afs/ir.stanford.edu/software/matlab-2011b/bin/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/
example single matlab file run via qsub
Here's our helloworld.m:
disp('Hello World');
Here's a command to run that.
/afs/ir.stanford.edu/software/matlab-2011b/bin/matlab -nodesktop < helloworld.m
We want to run this same command via the job scheduling system. Let's write a job script.
$ cat matlab_example.script #!/bin/bash #$ -N matlab_example #$ -m bes #$ -M chekh@stanford.edu /afs/ir.stanford.edu/software/matlab-2011b/bin/matlab -nodesktop < /afs/ir/users/c/h/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
Search the farmshare-discuss archives for Matlab.