Mathematica
Mathematica is a computational software program used in many scientific, engineering, mathematical and computing fields. Whilst it is possible to use wolfram on the command line, you can use the GUI on Viking and harness Viking’s powerful compute nodes in the process.
As mentioned previously, when you first log into Viking you are logged into one of the two login nodes. These are for light work and simple testing so to use Mathematica on a compute node we will need to:
Log into Viking with
X11 forwardinge.g.ssh -X viking.york.ac.ukRequest a compute node with the
salloccommandsshinto the node where the resources were allocatedLoad the
Mathematica/13.3.1-GCCcore-11.3.0moduleRun
mathematicaand the GUI should appear locally
Note
For this to work you must be running an xserver on your local machine which will display the Mathematica window. On Linux this is most likely included and on Mac OSX 10.8 and up, you’ll need to install XQuartz.  For Windows 10 / 11 Xming is one solution however, it may be more problematic to get running on Windows so you may want to run a virtual desktop instead. Without a locally running xserver this will not work.
SSH forwarding
Log into Viking with the -X option: ssh -X abc123@viking.york.ac.uk replacing abc123 with your username. This option enables the X11 Forwarding over the ssh connection. This allows a program to run on Viking yet forward the window to our local machine where it is displayed.
Request resources
Use the salloc command to request some resources on Viking for example:
$ salloc --nodes=1 --ntasks=1 --cpus-per-task=8 --mem=16g --time=2:0:0
The resources may take a few minutes depending on your request and how busy Viking is, but when they are allocated you are able to ssh into the node where the resources are allocated.
SSH into the node
We have only been allocated the resources, currently we are still on the login node. To access the allocated resources we ssh into the corresponding node, again with the -X option. Slurm has a handy environment variable to help here $SLURM_NODELIST which we can use as follows:
$ ssh -X $SLURM_NODELIST
You should shortly be logged into the node and the command prompt will change for example:
[abc123@node051[viking2] ~]$
We are now logged into the compute node with the requested resources and ready to run Mathematica.
Run Mathematica
Load the Mathematica module. You can search for it with the module spider Mathematica and load it with the following:
$ module load Mathematica/13.3.1-GCCcore-11.3.0
Once loaded, run mathematica and after a short moment it should appear on your screen:
$ mathematica
Tidy up
When finished, exit Mathematica and we need to relinquish the resources which salloc granted us. After Mathematica has closed, on the terminal command line press Ctrl + d twice, once to exit the ssh session and log out of the compute node. The second time is to relinquish the job allocation. You should get confirmation in the terminal this has occurred. If needed, you can list all your queued jobs with squeue -u $USER and if you see something you wish to cancel you can use scancel followed by the JOBID from the previous command.