Using Mathematica on O2

How to run an interactive Mathematica shell

Find out which version of Mathematica is currently available on the cluster using the module command: 

module spider mathematica


then load the desired version, for example:

module load mathematica/12.1.1


You can now submit an interactive Mathematica job using the SLURM command srun for example, requesting 2GiB of memory:

Non-graphical Mathematica
srun -c 1 --pty -t 06:00:00 -p interactive --mem=2G math


To run Mathematica with full graphics, please first refer to our instructions for how to use X11 applications on O2. There are preliminary steps to make sure your desktop can use X11 forwarding to display graphics from O2.

After that, you can similarly submit a graphical Mathematica job. The command "mathematica" enables full graphics:

Graphical Mathematica job
srun -c 1 --pty -t 06:00:00 -p interactive --mem=2G mathematica


How to run a batch Mathematica job

You can run Mathematica scripts as batch jobs using the SLURM command sbatch and a submission script, for example:

module load mathematica/12.1.1
sbatch my_mathematica_job.sh

when my_mathematica_job.sh is a script like

#!/bin/bash
#SBATCH -c 1                               # Request one core
#SBATCH -t 01:00:00                        # Runtime in HH:MM:SS format
#SBATCH -p short                           # Partition to run in
#SBATCH --mem=100                          # Memory total in MiB (for all cores)


math -noprompt -run '<<your_mathematica_script.m'


Please check our other wiki pages to learn more about the scheduler (SLURM), the O2 cluster, the available partitions, etc.