Mathematica: Difference between revisions

From RCSWiki
Jump to navigation Jump to search
mNo edit summary
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Category:Mathematica]]
[[Category:Software]]
[[Category:ARC]]
<span id="contents"></span>
<span id="contents"></span>
 
__TOC__
= <span id="intro"></span>Introduction =
= <span id="intro"></span>Introduction =


Line 32: Line 28:
#SBATCH --nodes=1
#SBATCH --nodes=1
#SBATCH --time=00:30:00
#SBATCH --time=00:30:00
#SBATCH --mem=0
#SBATCH --mem=128gb
#SBATCH --partition=pawson-bf,apophis-bf,razi-bf,single,lattice,parallel,cpu2019,cpu2013
#SBATCH --partition=pawson-bf,apophis-bf,razi-bf,single,lattice,parallel,cpu2019,cpu2013


Line 60: Line 56:
</pre>
</pre>
For the case of million primes, the run took about 30 seconds on a compute node in one of the slowest partitions (single) on ARC.  The time and memory limits should be adjusted to match the requirements of your calculations, but, some testing is usually required to fine tune those settings.
For the case of million primes, the run took about 30 seconds on a compute node in one of the slowest partitions (single) on ARC.  The time and memory limits should be adjusted to match the requirements of your calculations, but, some testing is usually required to fine tune those settings.
= Support =
Please send any questions regarding using Mathematica on ARC to support@hpc.ucalgary.ca.
= Links =
[[ARC Software pages]]
[[Category:Mathematica]]
[[Category:Software]]
[[Category:ARC]]
{{Navbox ARC}}

Latest revision as of 19:36, 18 October 2023

Introduction

Mathematica (external link) is a general-purpose high-level programming package for both symbolic and numerical calculations.

The main purpose of this page is to show how to use Mathematica on the University of Calgary ARC (Advanced Research Computing) cluster. It is presumed that you already have an account an ARC and have read the material on reserving resources and running jobs with the Slurm job management system.

Licensing

At the University of Calgary, Information Technologies has purchased a site license for using Mathematica for teaching and learning and non-commercial research purposes. The software has been installed on the ARC cluster, where multiple instances can be run at the same time. When Mathematica starts up, it checks with a central license server.

For information about installing Mathematica on your own computer, see the Information Technologies Knowledge Base article on Mathematica.

Running Mathematica on the ARC cluster

Although it is possible to run Mathematica interactively (with or without a graphical user interface) on a compute node reserved with the Slurm salloc command, the expectation is that most calculations with Mathematica on ARC will be completed by submitting a batch job script to the Slurm job scheduler with the sbatch command.

Suppose that the following Mathematica code to print out the first million prime numbers is in a file, primes_list.m :

primeslist = Table[Prime[k],{k,1,1000000}];
Export["primes_1000000.out",primeslist,"Table","FieldSeparators"->" "];

Note that formatted Mathematica notebooks cannot be used directly. You need to convert your notebook to a text-format ".m" file, as discussed, for example, here (external link). The general idea is to mark cells to be executed as initialization cells and then use "File->Save as" menu item with the "Package" option to produce the .m file.

The following Slurm batch job script, primes_list.slurm, can be used to run the primes_list.m code on a single complete compute node.

#!/bin/bash
#SBATCH --nodes=1
#SBATCH --time=00:30:00
#SBATCH --mem=128gb
#SBATCH --partition=pawson-bf,apophis-bf,razi-bf,single,lattice,parallel,cpu2019,cpu2013

# Mathematica batch processing example.
# 2020-05-28.

# Select Mathematica command to run:
MATH=/global/software/mathematica/mathematica1101/bin/math

# Specify the name of the input file of Mathematica text commands:
INPUT=primes_list.m
OUTPUT=$(basename $INPUT .m)_${SLURM_JOB_ID}.out

echo "Current working directory is $(pwd)"
echo "Running on compute node $(hostname)"

echo "Starting run at: $(date)"

$MATH -noprompt -run -script $INPUT > $OUTPUT

echo "Finished with at: $(date)"

Note that the name of the executable for running Mathematica without a graphical interface is "math". Submit the job with

sbatch primes_list.slurm

For the case of million primes, the run took about 30 seconds on a compute node in one of the slowest partitions (single) on ARC. The time and memory limits should be adjusted to match the requirements of your calculations, but, some testing is usually required to fine tune those settings.

Support

Please send any questions regarding using Mathematica on ARC to support@hpc.ucalgary.ca.

Links

ARC Software pages