ALERT! Warning: your browser isn't supported. Please install a modern one, like Firefox, Opera, Safari, Chrome or the latest Internet Explorer. Thank you!
Startseite » ... » Zentrale Einrichtungen  » ZIH  » Wiki
phone prefix: +49 351 463.....

HPC Support

Operation Status

Ulf Markwardt: 33640
Claudia Schmidt: 39833 hpcsupport@zih.tu-dresden.de

Login and project application

Phone: 40000
Fax: 42328
servicedesk@tu-dresden.de

You are here: Compendium » Applications » Mathematics

Mathematics Applications

The following applications are installed at ZIH:

  Venus Triton Taurus module
Mathematica     x mathematica
Matlab   x x matlab
Octave     x octave
R   x x r
Please do not run expensive interactive sessions on the login nodes. Instead, use srun --pty ... to let the batch system place it on a compute node.

Mathematica

Mathematica is a general computing environment, organizing many algorithmic, visualization, and user interface capabilities within a document-like user interface paradigm.

To remotely use the graphical frontend one has to add the Mathematica fonts to the local fontmanager.

For a Linux workstation:
scp -r taurus.hrsk.tu-dresden.de:/sw/global/applications/mathematica/10.0/SystemFiles/Fonts/Type1/ ~/.fonts
xset fp+ ~/.fonts/Type1

For a Windows workstation:
You have to add additional mathematica fonts at your local PC. At the end of this webpage you can find an archive with these fonts (.zip)

If you use Xming as X-server at your PC (see also our Information about Remote access from Windos to Linux):
  1. Create a new folder "Mathematica" in the diretory "fonts" of the installation directory of Xming. (mostly: C:\Programme\Xming\fonts\)
  2. Extract the fonts archive into this new directory "Mathematica".
    In result you should have 2 directories "DBF" and "Type1".
  3. Add the path to these font files into the file "font-dirs".
    You can find it in C:\Programme\Xming\.
      # font-dirs
      # comma-separated list of directories to add to the default font path
      # defaults are built-ins, misc, TTF, Type1, 75dpi, 100dpi
      # also allows entries on individual lines
      C:\Programme\Xming\fonts\dejavu,C:\Programme\Xming\fonts\cyrillic
      C:\Programme\Xming\fonts\Mathematica\DBF
      C:\Programme\Xming\fonts\Mathematica\Type1
      C:\WINDOWS\Fonts


Mathematica and SLURM:
Please use the Batchsystem SLURM for running calculations. This is a small example for a batch script, that you should prepair and start with command
sbatch <scriptname>
File "mathtest.m" is your input script, that includes the calculation statements for mathematica. File "mathtest.output" will collect the results of your calculation.

#!/bin/bash  
#SBATCH --output=mathtest.out
#SBATCH --error=mathtest.err
#SBATCH --time=00:05:00
#SBATCH --ntasks=1

module load mathematica
math -run < mathtest.m > mathtest.output

(also https://rcc.uchicago.edu/docs/software/environments/mathematica/index.html)

Matlab

MATLAB is a numerical computing environment and programming language. Created by The MathWorks, MATLAB allows easy matrix manipulation, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs in other languages. Although it specializes in numerical computing, an optional toolbox interfaces with the Maple symbolic engine, allowing it to be part of a full computer algebra system.

Running MATLAB via the batch system could look like this (for 456 MB RAM per core and 12 cores reserved). Please adapt this to your needs!
  • SLURM (taurus, venus):
   module load matlab
srun -t 8:00 -c 12 --mem-per-cpu=456 --pty --x11=first bash
matlab

With following command you can see a list of installed software - also the different versions of matlab.

   module avail

Please choose one of these, then load the chosen software with the command:
   module load matlab/version

Or use:

   module load matlab

(then you will get the most recent Matlab version. Refer to the modules section for details.)

matlab interactive

  • if X-server is running and you logged in at the HPC systems, you should allocate a CPU for your work with command
     srun --pty --x11=first bash 
  • now you can call "matlab" (you have 8h time to work with the matlab-GUI)

matlab with script

  • you have to start matlab-calculation as a Batch-Job via command
     srun --pty matlab -nodisplay -r basename_of_your_matlab_script #NOTE: you must omit the file extension ".m" here, because -r expects a matlab command or function call, not a file-name.

NOTE: while running your calculations as a script this way is possible, it is generally frowned upon, because you are occupying Matlab licenses for the entire duration of your calculation when doing so. Since the available licenses are limited, it is highly recommended you first compile your script via the Matlab Compiler (mcc) before running it for a longer period of time on our systems. That way, you only need to check-out a license during compile time (which is relatively short) and can run as many instances of your calculation as you'd like, since it does not need a license during runtime when compiled to a binary.

You can find detailled documentation on the Matlab compiler at Mathworks: https://de.mathworks.com/help/compiler/

using the matlab compiler (mcc)

  • compile your .m script to a binary:
    mcc -m name_of_your_matlab_script.m -o compiled_executable -R -nodisplay -R -nosplash

This will also generate a wrapper script called run_compiled_executable.sh which sets the required library path environment variables in order to make this work. It expects $MCRROOT as an argument, which is set automatically when the matlab module has been loaded.
  • then run the binary via the wrapper script in a job (just a simple example, you should be using an sbatch script for that):
    srun ./run_compiled_executable.sh $MCRROOT

matlab parallel (with 'local' configuration)

  • If you want to run your code in parallel, please request as many cores as you need!
  • start a batch job with the number N <=12 of processes (Matlab is limited to 12)
  • example for N= 4:
     srun -c 4 --pty --x11=first bash
  • run Matlab with the GUI or the CLI or with a script
  • inside use
    matlabpool open 4
    to start parallel processing

  • example for 1000*1000 matrixmutliplication
     R = distributed.rand(1000);
     D = R * R

  • to close parallel task:
     matlabpool close

matlab parallel (with parfor)

  • start a batch job with the number N <=12 of processes (Matlab is limited to 12)
  • inside use
    matlabpool open N
    or
    matlabpool(N)
    to start parallel processing. It will use the 'local' configuration by default.
  • Use 'parfor' for a parallel loop, where the independent loop iterations are processed by N threads
  • Example:
        parfor i = 1:3
            c(:,i) = eig(rand(1000));
        end
  • see alsp
    help parfor

matlab parallel (with matlabpool)

  • you have to set up a configuration:
  • Parallel -> Manage Configurations
  • File -> New -> hpcserver(css)
  • Configuration name (Enter any name you like for the configuration)
  • Description (Enter any description for the configuration you like)
  • Root directory of MATLAB installation for workers (Please take care of the version number in the directory path)
  • Number of workers available to scheduler (cores you need)
  • HPC scheduler hostname (HPCSHN1)
  • Cluster Version (check on which system you are running your jobs)

  • to open 5 parallel tasks (in Command Window):
     matlabpool open 'your configuration' 4

  • example for 1000*1000 matrixmutliplication
     R = distributed.rand(1000);
     D = R * R

  • to close parallel task (in Command Window):
     matlabpool close

matlab parallel (with create task)

  • Construct a parallel job object using the default configuration.
     pjob = createParallelJob();

  • Add the task to the job (random 1000*1000 matrix).
     createTask(pjob, 'rand', 1, {1000,1000});

  • Set the number of workers (3 in this example) required for parallel execution.
     set(pjob,'MinimumNumberOfWorkers',3);
     set(pjob,'MaximumNumberOfWorkers',3);

  • Run the job.
     submit(pjob);

  • Wait for the job to finish running, and retrieve the job results.
     waitForState(pjob);
     out = getAllOutputArguments(pjob);

  • Destroy the job.
     destroy(pjob);

Octave

GNU Octave is a high-level language, primarily intended for numerical computations. It provides a convenient command line interface for solving linear and nonlinear problems numerically, and for performing other numerical experiments using a language that is mostly compatible with Matlab. It may also be used as a batch-oriented language.