This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ======= Mathematica Batch Jobs ======= === SLURM === In order to be able to use Mathematica, you need to load the program with the ''module load'' command <code> [username@l32]$ module load Mathematica # load the default Mathematica module [username@l32]$ module list # check loaded modules Currently Loaded Modulefiles: [...] 18) Mathematica/12.3.1 </code> (See also the introduction to the [[https://wiki.vsc.ac.at/doku.php?id=doku:slurm|module command.]]) Now, Mathematica can be called by <code> [username@l32]$ math </code> ==== Example: Parallel Mathematica Task ==== Mathematica script example ''math-vsc3.m'': <code> GetEnvironment["MATH_BIN"] math = Environment["MATH_BIN"] kernelsperhost = 16 hosts=Import["nodelist","List"]; Needs["SubKernels`RemoteKernels`"] $RemoteCommand = "ssh -x -f -l `3` `1` " <> math <> " -mathlink -linkmode Connect `4` -linkname '`2`' -subkernel -noinit" (* first host with one kernel less *) LaunchKernels[RemoteMachine[hosts[[1]], kernelsperhost-1]]; imin=2; imax=Length[hosts]; idelta=1; Do[ LaunchKernels[RemoteMachine[hosts[[i]], kernelsperhost]]; , {i, imin, imax, idelta}] primelist = ParallelTable[Prime[k], {k, 1, 20000000}]; Print[primelist] </code> sbatch job script ''jobPar.sh'': <code> #!/bin/bash # #SBATCH -J par #SBATCH -N 2 #SBATCH -L mathematica@vsc module purge module load Mathematica/10.0.2 # load desired version export MATH_BIN=`which math` #export MATH_PROC=16 scontrol show hostnames $SLURM_NODELIST > nodelist #execute prolog for getting access to license everywhere srun hostname math -run < math-vsc3.m </code> <code> [username@l32]$ sbatch jobPar.sh # submit your job [username@l32]$ squeue -u username # check state of your job </code> ==== remote kernel connection ==== The setup follows [[https://cc-mathematik.univie.ac.at/services/vsc3-cluster/remote-mathematica-kernel/|Local mathematica with remote kernel]] with the **Shell command to launch kernel:** for VSC3+ <code> /Users/<LOCAL-USERNAME>/Library/tunnel.sh <VSC-USERNAME>@localhost:9998 /opt/sw/x86_64/generic/Mathematica/11.3/bin/math `linkname` </code> for VSC4 <code> /Users/<LOCAL-USERNAME>/Library/tunnel.sh <VSC-USERNAME>@localhost:9998 /opt/sw/vsc4/VSC/x86_64/generic/Mathematica/12.3.1/bin/math `linkname` </code> Note that on VSC4, the salloc command [as described on the cc-mathematik.univie.ac.at web link] does not need the Mathematica license. Just leave the -L parameter away. doku/mathematica.txt Last modified: 2022/09/20 13:41by groda