Updated 2022-12-16
Run Mathematica Interactively On Cluster¶
Overview¶
- The main way to run Mathematica is interactively with notebook functionality. It can also be run text-based in the terminal, and (not recommended) can be run in batch mode with some work.
- This guide will focus on setting up the standard notebook functionality, using many cores to enable parallelism.
- Running just the Mathematica kernal in the terminal (text-based) will be covered as well
Parallelism¶
- Setting up Mathematica according to this guide will give you multiple cores on a compute node
- Unlike Matlab, once you start the Mathematica notebook, no extra setup must be performed to enable parallelism
- Parallelism is enabled in your code. Mathematica Parallel Documentation can be found here.
- This guide will also include a few samples of parallel code, straight from the Mathematica docs.
Set up Interactive Desktop on Phoenix OnDemand¶
- In order to access Phoenix OnDemand you must be connected to the GT VPN. If you do not already have the VPN set up, visit Configure the GT VPN
- Once connected to the VPN you can access the application at Phoenix OnDemand.
- Choose the
Slurm Interactive Apps
tab and selectInteractive Desktop
to setup and launch. - Setting up Interactive Desktop:
- Charge Account:
gts-<PI username> ("phx-pace-staff" works for trial. Required.)
- Quality of Service:
inferno
- Node Type:
GPU Tesla V100-16B or GPU Tesla V100-32B
- Nodes:
1
- Cores Per Node:
8 (Number of cores (CPUs) per node. Max: 24 cores per node.)
- GPUs Per Node:
1
- Memery Per Crore (GB):
Leave blank if unsure. Total memory for job is: nodes × cores × memory per core
- Number of hours:
1
- Charge Account:
- After the preceding details are entered, clik the
Launch
button - Once the
Launch Interactive Desktop
is an available option, click the button to open a Phoenix OnDemand Interactive Desktop to use for Mathematica
Load Mathematica¶
- Open terminal in the Interactive Desktop by clicking top left
Activities
> search forterminal
- All commands here on will be typed in the terminal
- To see available versions of Mathematica run:
module spider mathematica # lists available mathematica versions
module load mathematica/13.1 # loads mathematica
Open a Notebook and Run Code¶
- Simply click "open" and open notebooks (
.nb
files) as you normally would. Make sure you open your user folder when looking for.nb
files. Refer to the file transfer guide to get.nb
files on the cluster. - Or, click on
New Document
to create a new notebook *Additionally, you can sign in and access notebooks from the cloud - Once you open a notebook, using Mathematica is the same as usual
Parallelism Example¶
- In terms of setup, once you are up and running and have a notebook open, you do not have to do any additional steps to enable parallelism
- Instead, parallelism is achieved through code. There are many different ways to code parallelism, a great resource is the mathematica documentation on parallelism
- This example code uses the
Parallelize[expr]
function, which evaluates expr using automatic parallelization. Example Code from Mathematica documentation:
$TrigFunctions = {Sin, Cos, Sec, Csc, Tan, Cot, ArcSin, ArcCos,
ArcSec, ArcCsc, ArcTan, ArcCot};
Parallelize@
Table[Plot3D[Abs[f[x + I y]], {x, -2, 2}, {y, -2, 2},
MeshFunctions ->
Function @@@ { { {x, y, z}, Re[f[x + I y]]}, { {x, y, z},
Im[f[x + I y]]} },
MeshShading -> { {Orange, None}, {None, Green} }, PlotLabel -> f,
Ticks -> None, ImageSize -> 100], {f, $TrigFunctions}]
- Notebook should look like:
Saving and Transferring Notebooks¶
- Save as you normally would in the notebook environment (click save as / save)
- Notebook will be saved to a dir of your choice in your home folder
- To transfer notebook files off the cluster, you can use a number of file transfer techniques. Globus is recommended.
- Congratulations! You have succesfully run Mathematica on the cluster.