3. Specific Use Cases#

3.1. MATLAB#

MATLAB is available as a module, however it is not recommended to run intensive MATLAB calculations on Hydra: its performance is not optimal and parallel execution is not fully supported.

First check which MATLAB versions are available:

module spider MATLAB

Next load a suitable version:

module load MATLAB/2021a

Tip

Use the most recent version for new projects

It is possible to run MATLAB in console mode for quick tests. For example, with a MATLAB script called testmatlab.m, type:

matlab -batch "run('testmatlab.m');"

MATLAB scripts should be submitted to the queue in a job script. Before submitting, however, we highly recommend to first compile your script using the MATLAB compiler mcc (this can be done on the login node):

mcc -m testmatlab.m

This will generate a testmatlab binary file, as well as an executable run_testmatlab.sh shell script (and a few other files, which you can ignore). The shell script makes sure the environment is set correctly before executing the binary.

Now you can submit your matlab calculation as a batch job. Your job script should look like this:

1#!/bin/bash
2#SBATCH --time=01:00:00
3#SBATCH --cpus-per-task=1
4
5module load MATLAB/2021a
6
7./run_testmatlab.sh $EBROOTMATLAB &> testmatlab.out

The advantage of running a compiled matlab binary is that it does not require a license. We have only a limited number of MATLAB licenses that can be used at the same time, so in this way you can run your simulation even if the all licenses are in use.

See also

The mcc documentation for more information on using the MATLAB compiler.

3.2. R#

Depending on your needs there are different methods to use R in Hydra

  • Interactive sessions should be performed in the compute nodes

    1. Start an interactive job in a compute node adjusting the number of cores --cpus-per-task as appropriate (by default R only uses 1 core):

      srun --cpus-per-task=1 --pty bash -l
      
    2. Load your R module of choice (preferably a recent version):

      module load R/4.1.0-foss-2021a
      
    3. Start the interactive R shell:

      R
      
  • Scripts written in R can be executed with the command Rscript. A minimal job script for R only requires loading the R module and executing your scripts with Rscript

    1#!/bin/bash
    2#SBATCH --time=1:00:00
    3#SBATCH --cpus-per-task=1
    4
    5module load R/4.1.0-foss-2021a
    6
    7Rscript <path-to-script.R>
    

Tip

The quality of the graphics generated by R can be improved by changing the graphical backend to Cairo. Add the following lines to the file ~/.Rprofile to make these changes permanent for your user (create the file ~/.Rprofile if it does not exist)

1# Use cairo backend for graphics device
2setHook(packageEvent("grDevices", "onLoad"),
3    function(...) grDevices::X11.options(type='cairo'))
4
5# Use cairo backend for bitmaps
6options(bitmapType='cairo')

3.3. Gaussian#

The available modules for Gaussian can be listed with the command:

module --show-hidden spider Gaussian

We recommend using the module Gaussian/G16.A.03-intel-2017b for general use because its performance has been thoroughly optimized for Hydra. More recent modules, such as Gaussian/G16.B.01, should be used if you need any of their new features.

Gaussian jobs can use significantly more memory than the value specified by %mem in the input file or with g16 -m in the execution command. Therefore, it is recommended to submit Gaussian jobs requesting a total memory that is at least 20% larger than the memory value defined in the calculation.

Gaussian G16 should automatically manage the available resources and parallelization. However, it is known to under-perform in some circumstances and not use all cores allocated to your job. In Hydra, the command myresources will report the actual use of resources of your jobs. If any of your Gaussian calculations is not using all available cores, it is possible to force the total number of cores used by Gaussian G16 with the option g16 -p or by adding the Gaussian directive %nprocshared to the top of the input file.

The following job script is an example to be used for Gaussian calculations running on 1 node with multiple cores. In this case we are running a g16 calculation with 80GB of memory (-m=80GB), but requesting a total of 20 * 5GB = 100GB of memory (25% more). Additionally, we are requesting 20 cores for this job and automatically passing this setting to g16 with the option -p=${SLURM_CPUS_PER_TASK}, where ${SLURM_CPUS_PER_TASK} is an environment variable that contains the number of cores allocated to your job.

1#!/bin/bash
2#SBATCH --cpus-per-task=20
3#SBATCH --mem-per-cpu=5GB
4
5ml Gaussian/G16.A.03-intel-2017b
6
7g16 -p=${SLURM_CPUS_PER_TASK} -m=80GB < input_file.com > output_file.log

3.4. GaussView#

GaussView is a graphical interface used with the computational chemistry program Gaussian. GaussView is installed in Hydra and can be used alongside Gaussian to enable all property visualizations.

  1. Login to Hydra enabling X11 forwarding. Linux and macOS users can do so by adding the option -Y to the ssh command used for login. See below:

    ssh -Y <username>@login.hpc.vub.be
    
  2. Load the modules of GaussView

    • GaussView 6 with Gaussian/G16.A.03:

      module load GaussView/6.0.16
      
    • GaussView 6 with Gaussian/G16.B.01:

      module load Gaussian/G16.B.01
      module load GaussView/6.0.16
      
  3. Launch GaussView:

    gview.sh
    

Keep in mind that using a graphical interface in Hydra is currently rather slow. Thus, for regular visualization tasks, the HPC team recommends installing GaussView in your personal computer. Binary packages of GaussView are available for Linux, Mac, and Windows and are provided upon request to VUB-HPC Support.

3.5. matplotlib#

The HPC environment is optimized for the execution of non-ineractive applications in job scripts. Therefore, matplotlib is configured with a non-GUI backend (Agg) that can save the resulting plots in a variety of image file formats. The generated image files can be copied to your own computer for visualization or further editing.

If you need to work interactively with matplotlib and visualize its output from within Hydra, you can do so with the following steps

  1. Login to Hydra enabling X11 forwarding. Linux and macOS users can use the following command:

    ssh -Y username@login.hpc.vub.be
    
  2. Enable the TkAgg backend at the very beginning of your Python script:

    1import matplotlib
    2matplotlib.use('TkAgg')
    

    Note

    The function matplotlib.use() must be done before importing matplotlib.pyplot. Changing the backend parameter in your matplotlibrc file will not have any effect as the system-wide configuration takes precedence over it.

3.6. CESM/CIME#

The dependencies required to run CESM in Hydra are provided by the module CESM-deps. This module also contains the XML configuration files for CESM with the specification of machines, compiler and batch system of Hydra. Once CESM-deps is loaded, the configuration files can be found in ${EBROOTCESMMINDEPS}/machines.

The following steps show an example setup of a CESM/CIME case

  1. Load the module CESM-deps

    module load CESM-deps/2-intel-2019b
    
  2. All data files for CESM have to be placed in $VSC_SCRATCH/cesm (DIN_LOC_ROOT)

    mkdir $VSC_SCRATCH/cesm
    

    Users needing data located elsewhere (e.g. in a Virtual Organization) can create symlinks in their $VSC_SCRATCH to the corresponding location

    ln -sf $VSC_DATA_VO/cesm $VSC_SCRATCH/cesm
    
  3. Create the following folder structure for your CESM/CIME cases in $VSC_SCRATCH

    mkdir $VSC_SCRATCH/cesm/inputdata
    mkdir $VSC_SCRATCH/cesm/cases
    mkdir $VSC_SCRATCH/cesm/output
    mkdir $VSC_SCRATCH/cesm/sources
    
  4. Download the source code of CESM/CIME into $VSC_SCRATCH/cesm/sources:

    Clone a public release of CESM#
    cd $VSC_SCRATCH/cesm/sources
    git clone -b release-cesm2.1.3 https://github.com/ESCOMP/cesm.git cesm-2.1.3
    
    Clone external sources of CIME#
    cd $VSC_SCRATCH/cesm/sources/cesm-2.1.3
    ./manage_externals/checkout_externals
    
  5. Add the configuration settings for Hydra and Breniac to your CESM/CIME source code

    cd $VSC_SCRATCH/cesm/sources/cesm-2.1.3
    update-cesm-machines cime/config/cesm/machines/ $EBROOTCESMMINDEPS/machines/
    
  6. Optional Add support for iRODS

    Determine your version of CIME#
    $ cd $VSC_SCRATCH/cesm/sources/cesm-2.1.3
    $ git -C cime/ describe --tags
    cime5.6.32
    
    Apply the patches for the closest CIME version in $EBROOTCESMMINDEPS/irods#
    $ cd $VSC_SCRATCH/cesm/sources/cesm-2.1.3
    $ git apply $EBROOTCESMMINDEPS/irods/cime-5.6.32/*.patch
    
  7. The creation of a case follows the usual procedure for CESM. Create your case inside $VSC_SCRATCH/cesm/cases

    cd $VSC_SCRATCH/cesm/sources/cesm-2.1.3/cime/scripts
    ./create_newcase --case $VSC_SCRATCH/cesm/cases/name_of_case --res f19_g17 --compset I2000Clm50BgcCrop
    
  8. Your CESM case can now be setup, built and launched. You can do so manually from the login node using the standard procedure with the case.setup, case.build and case.submit scripts in the case folder.

    We also provide a job script called case.slurm to automatically perform all these steps in one go in the compute nodes. This approach minimizes wait times in the queue and ensures that the nodes building and running the case are compatible. You can copy the template in $EBROOTCESMMINDEPS/scripts/case.slurm to your case and modify it as needed (adding xmlchange or any other commands). Once the script is adapted to your needs, submit it to the queue with sbatch as any other job:

    Copy job template to your case folder#
    cd $VSC_SCRATCH/cesm/cases/name_of_case
    cp $EBROOTCESMMINDEPS/scripts/case.slurm $VSC_SCRATCH/cime/cases/name_of_case/
    
    Edit case.job if needed#
    $EDITOR case.slurm
    
    Submit your CESM job (adjust computational resources as needed)#
    sbatch --ntasks=40 --time=24:00:00 case.slurm
    

The module CESM-tools provides a set of tools commonly used to analyse and visualize CESM data. Nonetheless, CESM-tools cannot be loaded at the same time as CESM-deps because their packages have incompatible dependencies. Once you obtain the results of your case, unload any modules with module purge and load CESM-tools/2-foss-2019a to post-process the data of your case.

3.7. GAP#

The GAP shell has a strong focus on being used interactively, whereas on Hydra the preferred way to run calculations is by submitting job scripts. Nonetheless, it is possible to use the interactive shell of GAP in our compute nodes with the following steps

  1. Request an interactive job session and wait for it to be allocated:

    $ srun --cpus-per-task=4 --time=3:0:0 --pty bash -l
    srun: job <jobID> queued and waiting for resources
    srun: job <jobID> has been allocated resources
    vsc10xxx@node361 ~ $
    
  2. Load the module of GAP and start its shell as usual:

    vsc10xxx@node361 ~ $ module load gap/4.11.0-foss-2019a
    vsc10xxx@node361 ~ $ gap
    ********* GAP 4.11.0 of 29-Feb-2020
    * GAP * https://www.gap-system.org
    ********* Architecture: x86_64-pc-linux-gnu-default64-kv7
    [...]
    gap>
    

Submitting a job script using GAP is also possible and requires preparing two scripts. One is the usual job script to be submitted to the queue and the second one is the script with the commands for GAP.

  • The job script is a standard job script requesting the resources needed by your calculation, loading the required modules and executing the script with the code for GAP.

    Example job script for GAP#
    1#!/bin/bash
    2#SBATCH --time=60:0
    3#SBATCH --cpus-per-task=4
    4
    5module load gap/4.11.0-foss-2019a-modisomTob
    6
    7./gap-script.sh
    
  • The script gap-script.sh is a shell script that executes GAP and passes your code to it. It is necessary to execute GAP with the -A option and only load the required GAP packages at the beginning of your script to avoid issues.

    Example script to execute GAP in batch mode#
    1#!/bin/bash
    2gap -A -r -b -q << EOI
    3LoadPackage( "Example" );
    42+2;
    5EOI
    

    Important

    Keep in mind to make gap-script.sh executable with the command chmod +x gap-script.sh

3.8. Mathematica#

First check which Mathematica versions are available:

module spider Mathematica

Next load a suitable version:

module load Mathematica/12.0.0

Tip

Use the most recent version for new projects

Run Mathematica in console mode in the terminal for quick tests:

wolframscript

Mathematica scripts (Wolfram Language Scripts) should be submitted to the queue in a job script. In the following example, we run the Mathematica script testmath.wls

Example job script for Mathematica#
1#!/bin/bash
2#SBATCH --time=1:0:0
3#SBATCH --cpus-per-task=1
4
5module load Mathematica/12.0.0
6
7wolframscript -file testmath.wls

Tip

Mathematica code is not optimized for performance. However, it supports several levels of interfacing to C/C++. For example, you can speed up your compute intensive functions by compiling them with a C compiler from inside your Mathematica script.

3.9. Stata#

First check which Stata versions are available:

module spider Stata

Next load a suitable version:

module load Stata/16-legacy

Tip

Use the most recent version for new projects

Running Stata in console mode in the terminal for quick tests:

stata

Stata do-files should be submitted to the queue in a job script. In the following example, we run the Stata program teststata.do

1#!/bin/bash
2#SBATCH --time=1:0:0
3#SBATCH --cpus-per-task=1
4
5module load Stata/16-legacy
6
7stata-se -b do teststata

Upon execution, Stata will by default write its output to the log file teststata.log.

Note

The recommended version of Stata in batch mode is stata-se, because it can handle the larger datasets.

3.10. GROMACS#

3.10.1. Threading Models#

GROMACS supports two threading models, which can be used together:

  • OpenMP threads

  • thread-MPI threads: MPI-based threading model implemented as part of GROMACS, incompatible with process-based MPI models such as OpenMPI

There are two variants of the GROMACS executable:

  • gmx: recommended for all single-node jobs, supports both OpenMP threads and thread-MPI threads

  • gmx_mpi: for multi-node jobs: must be used with srun, only supports OpenMP threads

The number of threads must always be specified, as GROMACS sets it incorrectly on Hydra:

  • gmx: use option -nt to let GROMACS determine optimal numbers of OpenMP threads and thread-MPI threads

  • gmx_mpi: use option -ntomp (not -ntmpi or -nt), and set number of threads equal to 1

Running on 1 or more GPUs, by default GROMACS will:

  • detect the number of available GPUs, create 1 thread-MPI thread for each GPU, and evenly divide the available CPU cores between the GPUs using OpenMP threads. Therefore, --cpus-per-task should be a multiple of the number of GPUs. Always check in the log file that the correct number of GPUs is indeed detected.

  • optimally partition the force field terms between the GPU(s) and the CPU cores, depending on the number of GPUs and CPU cores and their respective performances.

3.10.2. Job Scripts#

To get good parallel performance, GROMACS must be launched differently depending on the requested resources (#nodes, #cores, and #GPUs). In the example job scripts given below, a molecular dynamics simulation is launched with run input file example.tpr:

  • single-node, multi-core

    1#!/bin/bash
    2#SBATCH --time=1:0:0
    3#SBATCH --cpus-per-task=4
    4
    5module load GROMACS/2020.4-foss-2020a-Python-3.8.2
    6
    7gmx mdrun -nt $SLURM_CPUS_PER_TASK -s example.tpr
    
  • multi-node

    1#!/bin/bash
    2#SBATCH --time=1:0:0
    3#SBATCH --ntasks=8
    4
    5module load GROMACS/2020.4-foss-2020a-Python-3.8.2
    6
    7srun gmx_mpi mdrun -ntomp 1 -s example.tpr
    
  • single-GPU, single-node, multi-core

    1#!/bin/bash
    2#SBATCH --time=1:0:0
    3#SBATCH --nodes=1
    4#SBATCH --gpus-per-node=1
    5#SBATCH --cpus-per-task=4
    6
    7module load GROMACS/2019.3-fosscuda-2019a
    8
    9gmx mdrun -nt $SLURM_CPUS_PER_TASK -s example.tpr
    
  • multi-GPU, single-node, multi-core

    1#!/bin/bash
    2#SBATCH --time=1:0:0
    3#SBATCH --nodes=1
    4#SBATCH --gpus-per-node=2
    5#SBATCH --cpus-per-task=8
    6
    7module load GROMACS/2019.3-fosscuda-2019a
    8
    9gmx mdrun -nt $SLURM_CPUS_PER_TASK -s example.tpr
    

See also

The chapter Getting good performance from mdrun in the GROMACS manual for more information on running GROMACS efficiently.

3.11. CP2K#

To get good parallel performance with CP2K in Hydra, it is important to disable multi-threading. Below is an example job script which runs the CP2K input file example.inp

1#!/bin/bash
2#SBATCH --time=1:0:0
3#SBATCH --cpus-per-task=4
4
5module load CP2K/7.1-intel-2020a
6export OMP_NUM_THREADS=1
7
8srun cp2k.popt -i example.inp -o example.out

3.12. PyTorch#

PyTorch internally uses threads to run in parallel, but it makes some assumptions to determine the number of threads that do not apply to Hydra. This usually results in jobs with too many threads, saturating the allocated cores and hindering its performance. For optimal performance, the total number of threads should be equal to the number of cores allocated to your job. PyTorch can be configured to follow this rule by adding the following lines near the beginning of your Python script:

1torch.set_num_threads(len(os.sched_getaffinity(0)))
2torch.set_num_interop_threads(1)

Note

If you are using Python multiprocessing on top of PyTorch, then your job will generate N threads for each PyTorch process (P). Resulting in a total number of threads N × P. In this case, you should adapt your job making sure that the number of requested cores is equal to the total number of threads (N × P).

3.13. ORCA#

Using ORCA in parallel has the particularity of having to execute orca including the full path of the executable. This can be easily achieved by relying on the $EBROOTORCA environment variable, which always points to the installation directory of ORCA. Additionally, ORCA handles MPI on its own, so it is not necessary to explicitly use mpirun or srun with it.

Example job script for ORCA#
1#!/bin/bash
2#SBATCH --time=3:00:00
3#SBATCH --ntasks=8
4
5module load ORCA/5.0.1-gompi-2021a
6
7$EBROOTORCA/bin/orca example.inp

The previous example uses 8 parallel tasks (--ntasks=8). Keep in mind to always define the number of processors in ORCA (%PAL NPROCS 8 END) to be the number of tasks in your job.

Warning

ORCA v5.0.0 has a bug that causes parallel jobs using exactly 1 task per node to fail. Use version 5.0.1 to solve this issue.

3.14. SRA-Toolkit#

The NCBI-VDB client in SRA-Toolkit has to be configured upon first use. The configuration covers data download and storage settings in your account in Hydra. The main setting is defining the location of your user public repository. We recommend using a folder in $VSC_DATA or $VSC_SCRATCH, otherwise you might quickly fill up your home directory.

Set your user public repository in VSC_DATA#
mkdir $VSC_DATA/ncbi
vdb-config --set /repository/user/main/public/root=$VSC_DATA/ncbi

Starting with v2.10.0, it is also possible to always store the data in the current working directory (whatever it is at the moment of execution). This option might be useful if you do not need to maintain a permanent data folder and just want to download the required data for your job on-the-fly. However, make sure to delete the data directories once your job completes, otherwise your scratch might fill up after multiple job runs.

Always use current working directory to download data#
vdb-config --prefetch-to-cwd

The complete set of options can be configured with the command vdb-config -i

3.15. AlphaFold#

AlphaFold is installed for the Nvidia Ampere GPUs in Hydra. Submit your jobs with the options --gpus-per-node=1 --partition=ampere_gpu to specifically request one of those GPUs.

Example job script for AlphaFold#
 1#!/bin/bash
 2#SBATCH --partition=ampere_gpu
 3#SBATCH --nodes=1
 4#SBATCH --gpus-per-node=1
 5#SBATCH --cpus-per-gpu=8
 6#SBATCH --mem-per-cpu=8G
 7
 8export CUDA_MPS_PIPE_DIRECTORY=$TMPDIR/nvidia-mps-pipe
 9export CUDA_MPS_LOG_DIRECTORY=$TMPDIR/nvidia-mps-log
10nvidia-cuda-mps-control -d
11
12module load AlphaFold/2.1.1-foss-2021a-CUDA-11.3.1
13
14run_alphafold.py \
15    --model_preset=monomer_casp14 \
16    --fasta_paths=<protein_sequence>.fasta \
17    --output_dir=$SLURM_SUBMIT_DIR

You only need the sequence file (FASTA format) of the protein for your job. We provide the full datasets for AlphaFold in a central location accessible to all users. The path to those datasets is /databases/bio/alphafold-<version>, where <version> is any of the installed versions of AlphaFold. The software modules of AlphaFold are configured to use the datasets in this shared central location by default.

The datasets in /databases can be directly used in your jobs. However, the performance of the shared storage can still be a bottleneck in your jobs as the workload imposed by AlphaFold (mainly the HHblits query) is very intensive in random read patterns. We have a caching system in place that greatly improves access times, but it is only beneficial to series of runs (in a single job or multiple jobs) using common DBs and executed in the same node.

Hydra has two nodes specially suited to run AlphaFold. These 2 nodes have a very fast local scratch storage made of SSD drives with a total capacity of 5.9 TB. Therefore, the performance of the HHblits query can be improved by copying the DBs to the local $TMPDIR of the compute node running your job. You can submit your jobs specifically to these two new nodes by using the sbatch option --constraint="alphafold".

Once the selected DBs are in the temporary storage, you can update the $ALPHAFOLD_DATA_DIR environment variable after having loaded the AlphaFold module to change the location of its data dir:

Change default data dir of AlphaFold#
module load AlphaFold/2.1.1-foss-2021a-CUDA-11.3.1
cp -a $ALPHAFOLD_DATA_DIR $TMPDIR/alphafold-data-dir
export ALPHAFOLD_DATA_DIR="$TMPDIR/alphafold-data-dir"

3.16. GAMESS-US#

GAMESS-US has its own command tool rungms to launch its simulations in parallel. Using mpirun or srun is not needed.

Example job script for GAMESS-US#
1#!/bin/bash
2#SBATCH --time=6:00:00
3#SBATCH --cpus-per-task=1
4#SBATCH --ntasks-per-node=4
5#SBATCH --nodes=2
6
7module load GAMESS-US/20210930-R2-p1-gompi-2021a
8
9rungms <your_project>.inp $EBVERSIONGAMESSMINUS $SLURM_NTASKS $SLURM_NTASKS_PER_NODE > <your_project>.out

This example job will request 2 nodes with 4 CPU cores per node. If you need more cores, increase the number of nodes (preferably) or/and the number of tasks per node. The job script will automatically pass those values to rungms with the $SLURM_ variables. Replace <your_project> with the name of your project files.

GAMESS-US is configured to use the storage in your $VSC_SCRATCH. All the files generated by GAMESS-US will be located in specific folders for each of your jobs.