Howto OG matlab tutorial

From ImageWiki

(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
-
Assume that I have matlab script that I want to start. All files for this example are stored in /home/kimstp/test_officegrid.
+
Assume that I have matlab script that I want to start. All files for this example are stored in /home/sporring/test_officegrid.
The matlab script is called mytestscript.m and looks like this:
The matlab script is called mytestscript.m and looks like this:
Line 23: Line 23:
-
In order to setup the environment and start matlab I have made a script called run.sh:
+
My program, mytestscript.m, on the server is located in /home/sporring/test_officegrid.  In order to setup the environment and start matlab I have made a script called run.sh:
-
  #!/bin/sh
+
#!/bin/sh
-
                                                                               
+
 
-
  export MATLABPATH=/home/kimstp/test_officegrid
+
cd /home/sporring/test_officegrid;
-
  /usr/local/bin/matlab -nodesktop -nojvm -nosplash -r mytestscript
+
/usr/local/bin/matlab -nodesktop -nojvm -nosplash -logfile matlab.out -r mytestscript
    
    
After creating this file, you should make it executable as a script by:
After creating this file, you should make it executable as a script by:
   chmod u+x run.sh
   chmod u+x run.sh
                                                                                
                                                                                
 +
Now we are ready to start the script as an OG job. Login to imagediskserver3 (192.168.10.103) and using the command line interface do the following:
 +
  og_shcmd -i -p linux /home/sporring/test_officegrid/run.sh
-
Now we are ready to start the script as an OG job. Login to imagediskserver3 (192.168.10.103) and using the CLI do the following:
+
If you do not specify the walltime of the script it will stop your script after 1H. To ensure that the program will run for at least 1 day, use
-
   og_shcmd -i -p linux /home/kimstp/test_officegrid/run.sh
+
   og_shcmd -i -w 1:0:0:0 -p linux /home/sporring/test_officegrid/run.sh
-
 
+
-
Notes on -w --walltime (spitfire@diku.dk - 01/11-08)
+
-
If you do not specify the walltime of the script it will stop your script after 1H.
+
-
The program runs and writes and reads a file called data.mat.
+
The program runs and writes all matlab output in matlab.out, and reads a file called data.mat.
See section below on how to read back the text output from stdout and stderr. Or try to do:
See section below on how to read back the text output from stdout and stderr. Or try to do:

Revision as of 09:55, 10 October 2013

Assume that I have matlab script that I want to start. All files for this example are stored in /home/sporring/test_officegrid.

The matlab script is called mytestscript.m and looks like this:

 % This script is for testing Office Grid
                                                                               
 for i=1:10
   i
   X=ones(1,268435456); % Allocate 2 GB of memory
   pause(3)
   clear X;
 end
                                                                               
 % Remember to use absolute paths when reading and writing files. Like this
 X=10;
 save('/home/kimstp/test_officegrid/data.mat','X');
 clear all;
 load('/home/kimstp/test_officegrid/data.mat');
 X
                                                                               
 % Remember to call exit at the end of your matlab script (this is a problem
 % with our current matlab installation, ver. 7.3.0.298)
 exit();


My program, mytestscript.m, on the server is located in /home/sporring/test_officegrid. In order to setup the environment and start matlab I have made a script called run.sh:

  1. !/bin/sh

cd /home/sporring/test_officegrid; /usr/local/bin/matlab -nodesktop -nojvm -nosplash -logfile matlab.out -r mytestscript

After creating this file, you should make it executable as a script by:

 chmod u+x run.sh
                                                                             

Now we are ready to start the script as an OG job. Login to imagediskserver3 (192.168.10.103) and using the command line interface do the following:

 og_shcmd -i -p linux /home/sporring/test_officegrid/run.sh

If you do not specify the walltime of the script it will stop your script after 1H. To ensure that the program will run for at least 1 day, use

 og_shcmd -i -w 1:0:0:0 -p linux /home/sporring/test_officegrid/run.sh

The program runs and writes all matlab output in matlab.out, and reads a file called data.mat.

See section below on how to read back the text output from stdout and stderr. Or try to do:

 og_res -i <job_id>

Which should print the text output from your matlab script.

Personal tools