Biowulf at the NIH
RSS Feed
Octave on Biowulf

Octave logo GNU Octave is a high-level language, primarily intended for numerical computations. It provides a convenient command line interface for solving linear and nonlinear problems numerically, and for performing other numerical experiments using a language that is mostly compatible with Matlab. It may also be used as a batch-oriented language.

Many, but not all, Matlab .m scripts will run in Octave. MEX files (to call custom C or Fortran routines directly from Matlab) can be executed in Octave with some limitations.

Octave runs are typically slower than the equivalent Matlab run. However, Octave is not license-limited, so many more simultaneous runs are possible than with Matlab. Thus, on the Biowulf cluster Octave is most useful for projects which can be split into large numbers of independent simultaneous runs.

To set up the paths for Octave, it is easiest to use the modules commands as in the example below.
[user@biowulf ~]$ module avail octave

------------------ /usr/local/Modules/3.2.9/modulefiles --------------------
octave/3.2.4          octave/3.6.1(default)

[user@biowulf ~]$ module load octave

[user@biowulf ~]$ module list
Currently Loaded Modulefiles:
  1) octave/3.6.1

Get Octave in your path and run it:

% module load octave
% octave
GNU Octave, version 3.6.1
Copyright (C) 2012 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type `warranty'.

Octave was configured for "x86_64-unknown-linux-gnu".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/help-wanted.html

Read http://www.octave.org/bugs.html to learn how to submit bug reports.

For information about changes from previous versions, type `news'.

octave:1> 

 

Octave-Forge Packages

If you have a particular package from the Octave-Forge project that you would like installed, let us know and we will install it. Additionally, you can install your own Octave tool-boxes in your home directory. See the Octave-Forge web site for more information on add-on packages for Octave.

Submitting a single Octave batch job

Octave is primarily a command-line program. There are currently no Octave GUIs available on Biowulf.

  1. Create an Octave script. The following sample script takes a single argument from the command line.
    -------------file array.oct-------------------------------
    #!/bin/env octave -qf
    
    if( nargin != 1 )
        printf( "Usage: %s <integer>\n", program_name );
        return;
    endif
    
    len = str2num( argv(){1} );
    printf( "Working with array size %6d\n", len );
    
    clear a; 
    tic(); 
    for i=1:len
        a(i) = i; 
    endfor 
    time1 = toc();
    
    a = [1]; 
    tic(); 
    for i=2:len 
        a = [a i]; 
    endfor
    time2 = toc();
    
    printf( "The time taken for method 1 was %.4f seconds\n", time1 );
    printf( "The time taken for method 2 was %.4f seconds\n", time2 );
    -------------------------------------------------------------------
    
  2. Create a batch script for the job. Sample script:
    -------- file array.bat----------------------
    #!/bin/bash
    
    module load octave/3.6.1
    
    cd /data/user/mydir
    ./array.oct 10000 
    ---------------------------------------------
    
  3. Submit this job to the batch system with:
    qsub -l nodes=1 ./array.bat
    
The standard output and standard error from the Octave job will appear in the file array.o##### and array.e######, where ###### is the job number. To redirect only the Octave output into a file, you would use
./array.oct 10000 > filename.out
in the batch script above.

Submitting a swarm of Octave jobs

Octave on Biowulf is most useful for running large numbers of simultaneous independent jobs via the swarm program. The sample script array.oct above could be used to submit many jobs with different parameters.

  1. Create a swarm command file, with one line for each command you wish to run. Sample file:
    module load octave; /data/user/mydir/array.oct 1000 > array.out.1000
    module load octave; /data/user/mydir/array.oct 2000 > array.out.2000
    module load octave; /data/user/mydir/array.oct 3000 > array.out.3000
    ...
    module load octave; /data/user/mydir/array.oct 20000 > array.out.20000
    
  2. Submit this to the swarm program with swarm -f commandfilename. Sample session:
    [user@biowulf octave]$ swarm -f swarm.cmd
    291383.biobos
    291384.biobos
    [user@biowulf octave]$
    
The swarm program will submit the jobs, the Octave output will appear in the specified files, and the standard error and output will appear in files called swarm1n####.o and swarm1n####.e respectively, where ##### are the job numbers. [More about swarm]

Using Octave interactively on Biowulf

For debugging purposes, it is also possible to run Octave interactively. An interactive node should be allocated for this purpose. Sample session (user input in bold):

[susanc@biowulf ~]$ qsub -I -l nodes=1
qsub: waiting for job 290150.biobos to start
qsub: job 290150.biobos ready

p226    job-busy           interactive
[susanc@p226 ~]$ module load octave
[susanc@p226 ~]$ octave
GNU Octave, version 3.6.1
Copyright (C) 2012 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type `warranty'.

Octave was configured for "x86_64-unknown-linux-gnu".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/help-wanted.html

Read http://www.octave.org/bugs.html to learn how to submit bug reports.

For information about changes from previous versions, type `news'.

octave:1>a=1+1
a =  2
octave:2>  sin(a)
ans = -0.27942
octave:3> a=5*pi
x =  15.708
octave:4> sin(a)
ans =  6.1230e-16
octave:6> quit
[susanc@p226 ~]$ exit
logout

qsub: job 290150.biobos completed
[susanc@biowulf ~]$

Documentation