[ Skip to the content ]

Institute of Formal and Applied Linguistics Wiki


[ Back to the navigation ]

Table of Contents

ÚFAL Grid Engine (LRC)

LRC (Linguistic Research Cluster) is a name of ÚFAL's computational grid/cluster, which has (as of 2018/06) about 1728 CPU cores (65 servers + 10 submission heads), with a total 7.2 TiB of RAM. It uses (Sun/Oracle/Son of) Grid Engine software (SGE) for job scheduling etc. You can submit many computing tasks (jobs) at once, they will be placed in a queue and once a machine (slot) with the required capabilities (e.g. RAM, number of cores) is available, your job will be executed (scheduled) on this machine. This way we can maximize the usefulness of the computing resources and divide it among users in a fair way.

If you need GPU processing, see a special page about our GPU cluster called DLL (which is actually a subsystem of LRC with an independent queue gpu-ms.q).
TODO: describe alternatives, e.g.: MetaCentrum / Cesnet cluster (all MFF students can use it), Amazon EC2, Microsoft Azure (some colleagues may have sometime free vouchers).

TODO: IN 2022 MOVING FROM SGE TO SLURM (see slurm guidelines) – commands like qsub and qstat will stop working!

List of Machines

Last update: 2017/06. All machines have Ubuntu 18.04.
Some machines are at Malá Strana (ground floor, new server room built from Lindat budget), some are at Troja (5 km north-east).
If you need to quickly distinguish which machine is located where, you can use your knowledge of Trojan war-related heroes, qhost -q, or the tables below.

AVX instructions

Troja (cpu-troja.q)

Name CPU type GHz cores RAM(GB) note
achilles[1-8] Intel(R) Xeon(R) CPU E5-2630 v3 2.4 31 123 AVX enabled
hector[1-8] Intel(R) Xeon(R) CPU E5-2630 v3 2.4 31 123 AVX enabled
helena[1-8] Intel(R) Xeon(R) CPU E5-2630 v3 2.4 31 123 AVX enabled
paris[1-8] Intel(R) Xeon(R) CPU E5-2630 v3 2.4 31 123 AVX enabled

MS = Malá Strana (cpu-ms.q)

Name CPU type and flags GHz cores RAM(GB) note
hydra[1-4] AMD Opteron SSE4 AVX 2.6 15 122 AVX enabled
orion[1-8] Intel(R) Xeon(R) CPU E5-2630 v4 2.2 39 122 AVX enabled
belzebub Intel Xeon SSE4 AVX 2.9 31 249 AVX enabled
iridium Intel Xeon SSE4 1.9 15 501

Submit hosts / test machines

Name CPU type GHz cores RAM(GB) note
sol[1-8] Intel(R) Xeon(R) CPU E5-2630 v3 2.4 7 28 you can ssh here and compute or submit jobs
lrc[12] Intel(R) Xeon(R) CPU E5-2630 v4 2.2 4 4 you can submit jobs here or monitor job execution - NO COMPUTATION IS ALLOWED HERE !!!

You can ssh to one of the sol machines and submit jobs from here. It is allowed to compute here, which is useful e.g. when you have a script which submits your jobs, but it also collects statistics from the jobs outputs (and possibly submits new jobs conditioned on the statistics). However, the sol machines are relatively slow and may be occupied by your colleagues, so for bigger (longer) tasks, always prefer submission as separate jobs.

Installation

Add the following line into your '~/.bash_profile'.

source /opt/LRC/sge_profile

Or call one of these scripts directly:

/opt/LRC/common/settings.sh (for bash) 
/opt/LRC/common/settings.csh (for tcsh/csh)

This detects if you are on one of the cluster machines (including sol) and sets env variables accordingly. It also prints a status message.
Usually, this is the first line of your '~/.bash_profile' and the second-and-last line is

[ -f ~/.bashrc ] && source ~/.bashrc

Make sure you have correctly configured locale (otherwise qrsh may not show accented letters in less and you may get errors when printing utf8 on stdout/stderr from your script in qsub). For example add the following line to your ~/.bashrc:

export LC_ALL=en_US.UTF-8

If you are curious about purpose of .bashrc and .bash_profile and you need to know when they should be used you may read this.

Basic usage

First, you need to ssh to one of the submit hosts (sol[1-10]). The full address is (for example) sol1.ufal.hide.ms.mff.cuni.cz, but you can use just ssh sol1 (“hide” means it is accessible only from the ÚFAL network, not from outside; if working from home/Eduroam, you need to login/VPN to the ÚFAL network first).
In the following tutorial, we will prepare a wrapper shell script script.sh with a toy task. In practice you can name the script whatever you want and you can execute the real task, e.g. a Python/Perl/… script. It is recommended to use the wrapper shell scripts, but with -b y (see advanced usage) you can execute a Python/Perl/… directly without any wrapper.

ssh sol1
echo 'hostname; pwd; echo The second parameter is $2' > script.sh
  # prepare a shell script describing your task
qsub -cwd -j y script.sh Hello World
  # This submits your job to the default queue, which is currently ''cpu-*.q''.
  # Usually, there is a free slot, so the job will be scheduled within few seconds.
  # We have used two handy qsub parameters:
  #  -cwd  ... the script is executed in the current directory (the default is your home)
  #  -j y  ... stdout and stderr outputs are merged and redirected to a file (''script.sh.o$JOB_ID'')
  # We have also provided two parameters for our script "Hello" and "World".
  # The qsub prints something like
  #   Your job 121144 ("script.sh") has been submitted
qstat
  # This way we inspect all our jobs (both waiting in queue and scheduled, i.e. running).
qstat -u '*' | less
  # This shows jobs of all users.
qstat -j 121144
  # This shows detailed info about the job with this number (if it is still running).
less script.sh.o*
  # We can inspect the job's output (in our case stored in script.sh.o121144).
  # Hint: if the job is still running, press F in 'less' to simulate 'tail -f'.

The output of our job should look like:

LRC:ubuntu 14.04: 8.1.7a Son of Grid Engine variables set...
lucifer5
/home/popel/tmp
The second parameter is World
======= EPILOG: Tue Sep 26 19:49:05 CEST 2017
== Limits:   
== Usage:    cpu=00:00:00, mem=0.00000 GB s, io=0.00000 GB, vmem=N/A, maxvmem=N/A
== Duration: 00:00:02 (2 s)

Our admins configured the SGE to print some extra info on stderr: the first line and then the epilog.
The mem=XY GB s means gigabytes of RAM used times the duration of the job in seconds, so don't be afraid XY is usually a very high number (unlike in this toy example).
The maxvmem means the peak virtual memory consumption (which is useful for setting h_vmem, see below).

qdel 121144
  # This way you can delete ("kill") a job with a given number, or comma-or-space separated list of job numbers.
qdel \*
  # This way you can delete all your jobs. Don't be afraid - you cannot delete others jobs.

Rules

The purpose of these rules is to prevent your jobs to damage the work of your colleagues and to divide the resources among users in a fair way.

Memory

Advanced usage

qsub -q cpu-troja.q
This way your job is submitted to the Troja queue. The default is cpu-*.q. You can also use e.g.
-q '(cpu-t*|cpu-m*)' to submit on any machine in those two queues (but don't use -q '*' as this includes also gpu.q),
-q '*@hector[14]' to submit on hector1 or hector4,
-q 'cpu-*@!(hector*|iridium)' to submit on any troja/ms machine except hectors and iridium.
However, usually you should specify just the queue (cpu-troja.q vs. cpu-ms.q), not a particular machine, and instead use -l to specify the needed resources in a general way.

qsub -l
See man complex (run it on lrc or sol machines) for a list of possible resources you may require (in addition to mem_free etc. discussed above).

qsub -p -200
Define a priority of your job as a number between -1024 and 0. Only SGE admins may use a number higher than 0. In January 2018, we changed the default to -100 (it used to be 0). Please, do not use priority between -99 and 0 for jobs taking longer than a few hours, unless it is absolutely necessary for a deadline. In that case, please notify other GPU users. You should ask for lower priority (-1024..-101) if you submit many jobs at once or if the jobs are not urgent. SGE uses the priority to decide when to start which pending job in the queue (it computes a real number called prior, which is reported in qstat, which grows as the job is waiting in the queue). Note that once a job is started, you cannot “unschedule” it, so from that moment on, it is irrelevant what was its priority.

qsub -o LOG.stdout -e LOG.stderr
redirect std{out,err} to separate files with given names, instead of the defaults $JOB_NAME.o$JOB_ID and $JOB_NAME.e$JOB_ID.

qsub -@ optionfile
Instead of specifying all the qsub options on the command line, you can store them in a file (you can use # comments in the file). See also In-script options.

qsub -a 12312359
Execute your job no sooner than at the given time (in [YY]MMDDhhmm format). An alternative to sleep 3600 && qsub … &.

qsub -b y
Treat script.sh (or whatever is the name of the command you execute) as a binary, i.e. don't search for in-script options within the file, don't transfer it to the qmaster and then to the execution node. This makes the execution a bit faster and it may prevent some rare but hard-to-detect errors caused SGE interpreting the script. The script must be available on the execution node via NFS, Lustre (which is our case), etc. With -b y (shortcut for -b yes), script.sh can be an executable script or a binary (and you must provide full path, e.g. ./script.sh). With -b n (which is the default for qsub), script.sh must be a script (text file).

qsub -M popel@ufal.mff.cuni.cz,rosa@ufal.mff.cuni.cz -m beas
Specify the emails where you want to be notified when the job has been b started, e ended, a aborted or rescheduled, s suspended.
The default is now -m a and the default email address is forwarded to you (so there is no need to use -M). You can use -m n to override the defaults and send no emails.

qsub -hold_jid 121144,121145 (or qsub -hold_jid get_src.sh,get_tgt.sh)
The current job is not executed before all the specified jobs are completed.

qsub -now y
Start the job immediately or not at all, i.e. don't put it as pending to the queue. This is the default for qrsh, but you can change it with -now n (which is the default for qsub).

qsub -N my-name
By default the name of a job (which you can see e.g. in qstat) is the name of the script.sh. This way you can override it.

qsub -S /bin/bash
The hashbang (!#/bin/bash) in your script.sh is ignored, but you can change the interpreter with -S. I think /bin/bash is now (2017/09) the default (but it used to be csh).

qsub -v PATH[=value]
Export a given environment variable from the current shell to the job.

qsub -V
Export all environment variables. (This is not so needed now, when bash is the default interpreter and it seems your ~/.bashrc is always sourced.)

qsub -soft -l … -hard -l … -q …
By default, all the resource requirements (specified with -l) and queue requirements (specified with -q) are hard, i.e. your job won't be scheduled unless they can be fulfilled. You can use -soft to mark all following requirements as nice-to-have. And with -hard you can switch back to hard requirements.

qsub -sync y
This causes qsub to wait for the job to complete before exiting (with the same exit code as the job). Useful in scripts.

qalter
You can change some properties of already submitted jobs (both waiting in the queue and running). Changeable properties are listed in man qsub.

man qsub qstat qalter qhold queue_conf sge_types complex
Find out all the gory details which are missing here. You'll have to do it one day anyway:-).

qsub wrappers

If you often run (ad-hoc) bash commands via qsub, check ~bojar/tools/shell/qsubmit or ~stepanek/bin/qcmd, which allow you to enter the command on command line without creating any temp script files. The wrappers have also other features (some qsub options have changed default values). qcmd is older, but unlike qsubmit it has POD documentation, correct time computation and you don't need to quote the command.

qunhold

~stepanek/bin/qunhold tries to keep the number of running SGE jobs under a given threshold: all jobs over the threshold are held. If the number of running jobs goes below the threshold (default: 100), 10 jobs (by default) are unheld. Beware: if your jobs submit new jobs, you can get far over the threshold!

Don't submit more than ca 5000 jobs with qunhold - it overloads the SGE queue and slows done e.g. qstat (and qunhold uses qstat internally).

sshcwd

This is useful not only when sshing to sol machines. Add the following lines to your ~/.bashrc.

function sshcwd () {
  # save the current history so that it is available
  # immediately on the remote machine
  history -a;
  # setup the working directory by setting WD, delete possible ".nfs/"
  ssh -X -Y -C -t $@ "WD='${PWD/.nfs\//}' /bin/bash --login -i";
}

# use WD to setup the working directory
if [ -n "$WD" ]; then
  echo "Autochanging dir to $WD" >&2
  cd $WD;
fi

alias sol1="sshcwd sol1.ufal.hide.ms.mff.cuni.cz"

In-script options

If you don't use -b y, you can write the qsub options into script.sh instead of providing them on the command line. So your script.sh can be e.g.

#$ -l mem_free=10G,act_mem_free=10G,h_vmem=10G
#$ -pe smp 8
#$ -cwd -j y
#$ -N name-of-my-job
./what/to/run

and you execute it now simply with qsub script.sh.

~/.sge_request

You can change the defaults for any option by creating a personal configuration file ~/.sge_request. For example, you can add there a line -m n, so you will get no email notifications (unless overridden from the command line or in-script options).

Array jobs

If you have a set of tasks (of the same type) and want to run them on multiple machines, use qsub -t.

If you use -tc, then SGE can handle array jobs of virtually any size. It only starts as many tasks as specified in -tc at any time, and each scheduling interval (15 seconds in our current configuration) it starts new tasks if less than the specified -tc limit are running. However, note that it means the maximum throughput is 4 * tc tasks per minute, so the individual array job tasks need to run for at least tens of seconds for this to be effective.

The advantage of array jobs over qunhold is that it does not overload the SGE job queue. Also if you start an array job, the others can see that it is an array job, how many individual tasks there are and how many of them have already finished.

Delete many jobs at once

For deleting all your jobs use qdel \*. For deleting array jobs (see above), you can use comma-separated ranges of task ids, e.g. qdel -t 1,10,50-100.
For deleting a range of (normal) job ids, you can use bash expansion (as an alternative to seq), e.g. qdel {17979..18028}.

Ssh to random sol

Ondřej Bojar suggests to add the following alias to your .bashrc (cf. sshcwd):

alias cluster='comp=$(( (RANDOM % 10) +1)); ssh -o "StrictHostKeyChecking no" sol$comp'

Job monitoring

Profiling

As stated above, you should always specify the exact memory limits when running your tasks, so that you neither waste RAM nor starve others of memory by using more than you requested. However, memory requirements can be difficult to estimate in advance. That's why you should profile your tasks first.

A simple method is to run the task and observe the memory usage reported in the epilog, but SGE may not record transient allocations. As documented in man 5 accounting and observed in qconf -sconf, SGE only collects stats every accounting_flush_time. If this is not set, it defaults to flush_time, which is preset to 15 seconds. But the kernel records all info immediately without polling, and you can view these exact stats by looking into /proc/$PID/status while the task is running.

You can still miss allocations made shortly before the program exits – which often happens when trying to debug why your program gets killed by SGE after exhausting the reserved space. To record these, use /usr/bin/time -v (the actual binary, not the shell-builtin command time). Be aware that unlike the builtin, it cannot measure shell functions and behaves differently on pipelines.

Obtaining peak usage of multiprocess applications is trickier. Detached and backgrounded processes are ignored completely by time -v and you get the maximum footprint of any children, not the sum of all maximal footprints nor the largest footprint in any instant.

If you program in C and need to know the peak memory usage of your children, you can also use the wait4() syscall and calculate the stats yourself.

If your job is the only one on a given machine, you can also look how much free memory is left when running the job (e.g. with htop if you know when is the peak moment).

Other

unset INTERACTIVE
/usr/bin/tty > /dev/null 2>&1
/usr/bin/test $? = 0 && INTERACTIVE=yes
...
if [ "$INTERACTIVE" ]; then
  ... commands only for truly interactive sessions ...
fi

TODO: Is this restriction still true (for our cluster)? E.g. .bash_profile with /net/projects/SGE/user/sge_profile prints info messages on stderr and it is OK.


[ Back to the navigation ] [ Back to the content ]