How to run Octave on maya

Introduction

On this page we’ll see how to use Octave on the maya cluster. Before proceeding, make sure you’ve read the how to run tutorial first. Octave is an open source mathematics package, similar in functionality to MATLAB.

To run the latest version of Octave on maya, load the module by entering:

[araim1@maya-usr1 ~]$ module load octave/3.8.1

Note that while you can run Octave from the default-environment without loading this module, doing so will result in utilizing an older version of Octave that has known issues. These issues have since been corrected in the latest version of Octave.

Example batch script

We’ll write a simple Octave script that says “hello”, and does some simple linear algebra operations.

[status, host] = system('hostname');
printf('Hello world from %s\n', host);

A = [1 3 5; 2 5 1; 2 3 8]
inv(A)
det(A)

Download: ../code/octave_hello/hello.m

We can launch it with a standard SLURM script

#!/bin/bash 
#SBATCH --job-name=hello_octave
#SBATCH --output=slurm.out
#SBATCH --error=slurm.err
#SBATCH --partition=develop

octave --silent --eval hello

Download: ../code/octave_hello/run.slurm

Now we launch the job

[araim1@maya-usr1 octave_hello]$ sbatch run.slurm
sbatch: Submitted batch job 2618
[araim1@maya-usr1 octave_hello]$ ls
hello.m  run.slurm  slurm.err  slurm.out
[araim1@maya-usr1 octave_hello]$ cat slurm.out
Hello world from n1

A =

   1   3   5
   2   5   1
   2   3   8

ans =

  -1.480000   0.360000   0.880000
   0.560000   0.080000  -0.360000
   0.160000  -0.120000   0.040000

ans = -25
[araim1@maya-usr1 octave_hello]$ 

Also note that hello.m can be run directly on the front end node, which is okay here because it’s a small job

[araim1@maya-usr1 octave_hello]$ octave --silent --eval hello
Hello world from maya-usr1.rs.umbc.edu

A =

   1   3   5
   2   5   1
   2   3   8

ans =

  -1.480000   0.360000   0.880000
   0.560000   0.080000  -0.360000
   0.160000  -0.120000   0.040000

ans = -25

[araim1@maya-usr1 octave]$ 

Running Octave interactively

Octave can also be used interatively on the front end node, as in the following example

[araim1@maya-usr1 octave_hello]$ octave --silent
octave:1> [status, host] = system('hostname')
status = 0
host = maya-usr1.rs.umbc.edu

octave:2> printf('Hello world from %s\n', host);
Hello world from maya-usr1.rs.umbc.edu

octave:3> A = [1 3 5; 2 5 1; 2 3 8]
A =

   1   3   5
   2   5   1
   2   3   8

octave:4> inv(A)
ans =

  -1.480000   0.360000   0.880000
   0.560000   0.080000  -0.360000
   0.160000  -0.120000   0.040000

octave:5> det(A)
ans = -25
octave:6> quit
[araim1@maya-usr1 octave_hello]$

As always, this should only be used for smaller computations. Intensive programs should be submitted to the compute nodes.