[ Skip to the content ]

Institute of Formal and Applied Linguistics Wiki


[ Back to the navigation ]

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
grid [2017/09/26 11:53]
popel
grid [2021/04/13 11:43]
127.0.0.1 external edit
Line 1: Line 1:
 ====== ÚFAL Grid Engine (LRC) ====== ====== ÚFAL Grid Engine (LRC) ======
  
-LRC (Linguistic Research Cluster) is a name of ÚFAL'CPU computational cluster, which has (as of 2017/09) about 1600 CPU cores (115 servers + submission heads), with a total 10 TiB of RAM.+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 [[https://en.wikipedia.org/wiki/Oracle_Grid_Engine|(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|GPU cluster called DLL]].+If you need GPU processing, see a special page about our [[:gpu|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).
  
-Cluster (shluk) neboli grid (mřížsíťje skupina počítačůna kterých běží software pro automatické umístění vašeho výpočtu na dosud nevytížený stroj. Cluster na ÚFALu se nazývá LRC (Linguistic Research Clustera clustrovací software na něm je (Sun/Oracle/Son of) Grid EngineDo clusteru jsou zařazené tyto počítače:+===== List of Machines ===== 
 +Last update: 2017/06. All machines have Ubuntu 18.04. 
 +Some machines are at Malá Strana (ground floornew 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 [[https://en.wikipedia.org/wiki/Trojan_War|Trojan war]]-related heroes, ''qhost -q'', or the tables below
  
-  * lrc.ufal.hide.ms.mff.cuni.cz: hlava clusteru. To znamená, že neslouží k výpočtům, ale ke správě fronty výpočtů, které se odesílají na výpočetní stroje v clusteru. Na hlavě se nemají pouštět žádné náročné výpočty a naopak na ostatní stroje v clusteru se mají výpočty odesílat výhradně prostřednictvím hlavy. Hlava má 2 procesory Intel Pentium D 3 GHz a 1 GB paměti. Ve skutečnosti existují hlavy dvě - lrc1 a lrc2, které sdílí IP adresu lrc.ufal.hide.ms.mff.cuni.cz. V případě výpadku jedné z hlav, přebírá kontrolu ta druhá.  +====== AVX instructions ======
-  * V následující tabulce je uveden seznam výpočetních uzlů clusteru (aktuální k 6.4.2012):+
  
-Jméno                   ^ CPU                         ^ RAM (GB)   OS               +==== Troja (cpu-troja.q) ==== 
-andromeda[1-13        2xCore4 AMD Opteron 2.8 Ghz 32         Ubuntu 10.04     +Name                ^ CPU type                                  ^ GHz ^cores ^RAM(GB)^ note 
-fireball[1-10         2xCore4 Intel Xeon 3 Ghz    32         | Ubuntu 10.04     +achilles[1-8      | Intel(R) Xeon(R) CPU E5-2630 v3           | 2.  31  123  |  AVX enabled    
-hyperion[1-10         2xCore2 Intel Xeon 3 Ghz    32         | Ubuntu 10.04     +hector[1-8        | Intel(R) Xeon(R) CPU E5-2630 v3           2.4 |   31 |  123  |  AVX enabled    
-lucifer[1-10          2xCore4 Intel Xeon 2.4 Ghz  128        Ubuntu 10.04     | +helena[1-8        | Intel(R) Xeon(R) CPU E5-2630 v3           2.4 |   31 |  123  |  AVX enabled    
-orion[1-10            2xCore4 Intel Xeon Ghz    32         Ubuntu 10.04     +paris[1-8         | Intel(R) Xeon(R) CPU E5-2630 v3           2.4 |   31 |  123   AVX enabled    | 
-tauri[1-10            2xCore4 Intel Xeon 3 Ghz    | 32         | Ubuntu 10.04     | + 
-| cosmos                  | 4xCore2 Intel Xeon 2.93 Ghz 256        Ubuntu 10.04     +==== MS = Malá Strana (cpu-ms.q) ==== 
-| belzebub                8xCore4 Intel Xeon 2.90 Ghz 256        Ubuntu 10.04     + 
-| iridium                 2xCore4 Intel Xeon 1.86 Ghz 512        Ubuntu 10.04     | +^ Name                ^ CPU type and flags              ^ GHz ^cores ^RAM(GB)^ note ^ 
-| twister[1,2]            | 2xCore4 Intel Xeon 2.4 Ghz  48         Ubuntu 10.04     | +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.  39  122  |   AVX enabled   
-Outside LRC cluster: +| belzebub            | Intel Xeon SSE4 AVX             2.  31  249  |   AVX enabled   
-Jméno                   ^ CPU                         ^ RAM (GB)   OS               +| iridium             | Intel Xeon SSE4                 1.  15  501       | 
-pandora[1-10]           2xCore2 Intel Xeon 2.6 Ghz  16         Ubuntu 10.04     + 
-sol[1-8,11-13         2xCore4 AMD Opteron Ghz   16         Ubuntu 10.04     |+<html><!-- 
 +sol5       fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca lahf_lm dtherm tpr_shadow 
 +sol7       fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx tm2 ssse3 cx16 xtpr pdcm dca lahf_lm dtherm tpr_shadow 
 +andromeda4 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc rep_good nopl nonstop_tsc extd_apicid pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt hw_pstate npt lbrv svm_lock nrip_save vmmcall 
 +hydra1     fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc extd_apicid amd_dcm aperfmperf pni pclmulqdq monitor ssse3 cx16 sse4_1 sse4_2 popcnt aes xsave avx lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs xop skinit wdt lwp fma4 nodeid_msr topoext perfctr_core perfctr_nb arat cpb hw_pstate npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold vmmcall 
 +fireball1  fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca lahf_lm dtherm tpr_shadow 
 +hyperion1  fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca lahf_lm dtherm tpr_shadow 
 +lucifer1   fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 popcnt aes lahf_lm kaiser tpr_shadow vnmi flexpriority ept vpid dtherm ida arat 
 +orion1     fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca lahf_lm dtherm tpr_shadow vnmi flexpriority 
 +orion7     fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx tm2 ssse3 cx16 xtpr pdcm dca lahf_lm dtherm tpr_shadow 
 +tauri1     fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca lahf_lm dtherm tpr_shadow 
 +cosmos     fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca lahf_lm dtherm tpr_shadow vnmi flexpriority 
 +belzebub   fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx lahf_lm epb kaiser tpr_shadow vnmi flexpriority ept vpid xsaveopt dtherm ida arat pln pts 
 +iridium    fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 x2apic popcnt lahf_lm dtherm tpr_shadow vnmi flexpriority ept vpid 
 +twister1   fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 popcnt lahf_lm ida arat epb dtherm tpr_shadow vnmi flexpriority ept vpid 
 +--> 
 +</html> 
 +=== Submit hosts / test machines === 
 +Name                ^ CPU type                        ^ GHz ^cores ^ RAM(GB) ^ note  
 +sol[1-8]           | Intel(R) Xeon(R) CPU E5-2630 v3 | 2.     28    | you can ssh here and compute or submit jobs 
 +lrc[12            | Intel(R) Xeon(R) CPU E5-2630 v4 | 2.2          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 =====
  
-**Pandora machines** are in a special cluster and queue **ms-guests.q** available for our colleagues from KSVI and for students of [[http://ufal.mff.cuni.cz/courses/npfl102|Data intensive computing]] (see the 2016 handouts if you missed the course). +Add the following line into your '~/.bash_profile'.
-**Sol machines** are for us - we can ssh there, submit jobs and also do computing (e.g. collecting statistics from the submitted jobs).+
  
-Frontovací systém umožňuje:+  source /opt/LRC/sge_profile
  
-  * využít na maximum výpočetní výkon +Or call one of these scripts directly:
-  * poslat mnoho úloh k řešení najednou, úlohy budou ale spuštěny teprve, když na to bude čas +
-  * "spravedlivě" dělit strojový čas mezi zájemce+
  
-===== Jak začít =====+  /opt/LRC/common/settings.sh (for bash)  
 +  /opt/LRC/common/settings.csh (for tcsh/csh)
  
-Jednou za život musíte provést [[Základní nastavení SGE]]abyste SGE mohli používat.+This detects if you are on one of the cluster machines (including sol) and sets env variables accordingly. It also prints a status message. 
 +Usuallythis is the first line of your '~/.bash_profile' and the second-and-last line is
  
-===== Ukázka užití SGE =====+  [ -f ~/.bashrc ] && source ~/.bashrc
  
-Tato posloupnost příkazů ukazujejak užít SGE:+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 [[https://stackoverflow.com/a/415444|this]]. 
 +   
 +===== Basic usage ===== 
 + 
 +Firstyou 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 [[internal:remote-access|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.
  
 <code> <code>
-ssh lrc2 +ssh sol1 
-  # přihlašte se na hlavu clusteru +echo 'hostname; pwd; echo The second parameter is $2' script.sh 
-echo "hostname; pwdskript.sh +  # prepare a shell script describing your task 
-  # vyrobte skript, který popisuje, co má úloha udělat +qsub -cwd -j y script.sh Hello World 
-qsub -cwd -j y skript.sh +  # This submits your job to the default queue, which is currently ''cpu-*.q''
-  # zařaďte úlohu do fronty+  # Usually, there is a free slot, so the job will be scheduled within few seconds
-  # Vlastně stačilo zavolat: qsub skript.sh +  # We have used two handy qsub parameters
-  # Ale dodatečné parametry zařídily+  #  -cwd  ... the script is executed in the current directory (the default is your home
-  #  -cwd  ... skript bude spuštěn v aktuálním adresáři (a nikoli homu) +  #  -j y  ... stdout and stderr outputs are merged and redirected to file (''script.sh.o$JOB_ID''
-  #  -V    ... proměnné z vašeho prostředí budou zkopírovány do prostředí skriptu +  # We have also provided two parameters for our script "Hello" and "World". 
-  #  -j y  ... standardní chybový výstup bude spojen (jako to dělá nohup+  # The qsub prints something like 
-  # Pořadí parametrů **je** důležité, co je za jménem skriptu, to se předává skriptu.+  #   Your job 121144 ("script.sh") has been submitted
 qstat qstat
-qstat -u '*'  +  # This way we inspect all our jobs (both waiting in queue and scheduled, i.e. running). 
-  # Podívejme se, jaké vaše úlohy běží+qstat -u '*' | less 
-  # SGE chvíli čeká, než skript opravdu spustíPro malinké úlohy tedy SGE může představovat +  # This shows jobs of all users. 
-  # zbytečné zpoždění+qstat -j 121144 
-  # -u '*' ukáže úlohy všech uživatelů na clusteri +  # This shows detailed info about the job with this number (if it is still running)
-cat skript.sh.oXXXXX +less script.sh.o* 
-  # vypište si výstup skriptuXXXXX je ID jobu, které bylo přiděleno +  # We can inspect the job's output (in our case stored in script.sh.o121144)
-  # qsubem. Čili druhé poslání do fronty starší log typicky nepřepíše.+  # Hint: if the job is still running, press F in 'less' to simulate 'tail -f'.
 </code> </code>
  
-A takto dopadl výstup našeho skriptu:+The output of our job should look like:
  
 <code> <code>
-Warningno access to tty (Bad file descriptor). +LRC:ubuntu 14.04: 8.1.7a Son of Grid Engine variables set... 
-Thus no job control in this shell. +lucifer5 
-sol2.ufal.hide.ms.mff.cuni.cz +/home/popel/tmp 
-/export/home/bojar+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/
 +== Duration: 00:00:02 (2 s)
 </code> </code>
  
-Další užitečné příkazy a parametry:+Our admins configured the SGE to print some extra info on stderrthe 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).
  
 <code> <code>
-qsub -o LOG.stdout -e LOG.stderr skript.sh +qdel 121144 
-  # když chcete přesměrovat výstup skriptu do určených souborů +  # This way you can delete ("kill") a job with a given numberor comma-or-space separated list of job numbers.
-qsub -S /bin/bash +
-  # když chceteaby skript běžel v bashi +
-qsub -+
-  # když chcete předat proměnné prostředí+
 qdel \* qdel \*
-  # když chcete zrušit všechny své joby (rušit cizí nesmíte)+  # This way you can delete all your jobs. Don't be afraid - you cannot delete others jobs.
 </code> </code>
  
 +===== 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.
  
 +  * Read about our [[internal:linux-network|network]] first (so you know that e.g. reading big data from your home in 200 parallel jobs is not a good idea, but regular cleanup of your data is a good idea). Ask your colleagues (possibly via [[internal:mailing-lists|devel]]) if you are not sure, esp. if you plan to submit jobs with unusual/extreme disk/mem/CPU requirements.
 +  * While your jobs are running (or queued), check your jobs (esp. previously untested setups) and your email (esp. [[internal:mailing-lists|devel]]) regularly. If you really need to leave e.g. for two-week vacation offline, consult it first with it@ufal (whether they can kill your jobs if needed).
 +  * You can ssh to any cluster machine, which can be useful e.g. to diagnose what's happening there (using ''htop'' etc.).
 +  * However, **never execute any computing manually** on a cluster machine where you are sshed (i.e. not via ''qsub'' or ''qrsh''). If you break this rule, your task will take CPU and memory, but the SGE will not know, so it may schedule other users' jobs on the same machine and **their jobs may fail** or run slowly. The sol machines are an exception from this rule.
 +  * For interactive work, you can use ''qrsh'', but please try to end the job (exit with Ctrl+D) once finished with your work, especially if you ask for a lot of memory or CPUs (see below). One semi-permanent qrsh job (with non-extreme CPU/mem requirements) per user is acceptable.
 +  * **Specify the memory and CPU requirements** (if higher than the defaults) and **don't exceed them**.
 +    * If your job needs more than one CPU (on a single machine) for most of the time, reserve the given number of CPU cores (and SGE slots) with <code>qsub -pe smp <number-of-CPU-cores></code> As you can see in [[#List of Machines]], the maximum is 32 cores. If your job needs e.g. up to 110% CPU most of the time and just occasionally 200%, it is OK to reserve just one core (so you don't waste). TODO: when using ''-pe smp -l mf=8G,amf=8G,h_vmem=12G'', which memory limits are per machine and which are per core?
 +    * If you are sure your job needs less than 1GB RAM, then you can skip this. Otherwise, if you need e.g. 8 GiB, you must always use ''qsub'' (or ''qrsh'') with ''-l mem_free=8G''. You should specify also ''act_mem_free'' with the same value and ''h_vmem'' with possibly a slightly bigger value. See [[#memory]] for details. TL;DR: <code>qsub -l mem_free=8G,act_mem_free=8G,h_vmem=12G</code> 
 +  * Be kind to your colleagues. If you are going to submit jobs that effectively occupy **more than one fifth of our cluster for more than several hours**, check if the cluster is free (with ''qstat -g c'' or ''qstat -u \*'') and/or ask your colleagues if they don't plan to use the cluster intensively in the near future. Note that if you allocate one slot (CPU core) on a machine, but (almost) all its RAM, you have effectively occupied the whole machine and all its cores. If you are submitting **more than 100 jobs**, consider using setting them a low priority (e.g. ''-p -1024'', see below) or use [[#qunhold]] or (even better) [[#array jobs]].
 +  * **Don't submit more than ca 5000 jobs at once**, even if you make sure that at most 100 are running/waiting and the rest is in the //hold// state (e.g. using ''qunhold''). More than 5000 jobs in the queue can overload the SGE, so then no one can execute ''qstat'' (or it takes too long).
  
  
 +=== Memory ===
  
-===== Pravidla pro správné používání clusteru =====+  * There are three commonly used options for specifying memory requirements: ''mem_free, act_mem_free'' and ''h_vmem''. Each has a different purpose. 
 +  * ''mem_free=1G'' means 1024×1024×1024 bytes, i.e. one [[https://en.wikipedia.org/wiki/Gibibyte|GiB (gibibyte)]]. ''mem_free=1g'' means 1000×1000×1000 bytes, i.e. one gigabyte. Similarly for the other options and other prefixes (k, K, m, M). 
 +  * **mem_free** (or mf) specifies a //consumable resource// tracked by SGE and it affects job scheduling. Each machine has an initial value assigned (slightly lower than the real total physical RAM capacity). When you specify ''qsub -l mem_free=4G'', SGE finds a machine with mem_free >4GB, and subtracts 4GB from it. This limit is not enforced, so if a job exceeds this limit, **it is not automatically killed** and thus the SGE value of mem_free may not represent the real free memory. The default value is 1G. By not using this option and eating more than 1 GiB, you are breaking the rules. 
 +  * **act_mem_free** (or amf) is a ÚFAL-specific option, which specifies the real amount of free memory (at the time of scheduling). You can specify it when submitting a job and it will be scheduled to a machine with at least this amount of memory free. In an ideal world, where no jobs are exceeding their ''mem_free'' requirements, we would not need this options. However, in real world it is recommended to use this option with the same value as ''mem_free'' to protect your job from failing with out-of-memory error (because of naughty jobs of other users). 
 +  * **h_vmem** is equivalent to setting ''ulimit -v'', i.e. it is a hard limit on the size of virtual memory (see RLIMIT_AS in ''man setrlimit''). If your job exceeds this limit, memory allocation fails (i.e., malloc or mmap will return NULL), and your job will probably crash on SIGSEGV. TODO: according to ''man queue_conf'', the job is killed with SIGKILL, not with SIGSEGV. Note that ''h_vmem'' specifies the maximal size of **allocated_memory, not used_memory**, in other words it is the VIRT column in ''top'', not the RES column. SGE does not use this parameter in any other way. Notably, job scheduling is not affected by this parameter and therefore there is no guarantee that there will be this amount of memory on the chosen machine. The problem is that some programs (e.g. Java with the default setting) allocate much more (virtual) memory than they actually use in the end. If we want to be ultra conservative, we should set ''h_vmem'' to the same value as ''mem_free''. If we want to be only moderately conservative, we should specify something like h_vmem=1.5*mem_free, because some jobs will not use the whole mem_free requested, but still our job will be killed if it allocated much more than declared. The default effectively means that your job has no limits. 
 +    * For GPU jobs, it is usually better to use **h_data** instead of **h_vmem**. CUDA driver allocates a lot of "unused" virtual memory (tens of GB per card), which is counted in ''h_vmem'', but not in ''h_data''. All usual allocations (''malloc'', ''new'', Python allocations) seem to be included in ''h_data''
 +  * It is recommended to **profile your task first** (see [[#profiling]] below), so you can estimate reasonable memory requirements before submitting many jobs with the same task (varying in parameters which do not affect memory consumption). So for the first time, declare mem_free with much more memory than expected and ssh to a given machine and check ''htop'' (sum all processes of your job) or (if the job is done quickly) check the epilog. When running other jobs of this type, set ''mem_free'' (and ''act_mem_free'' and ''h_vmem'') so you are not wasting resources, but still have some reserve. 
 +  * **s_vmem** is similar to ''h_vmem'', but instead of SIGSEGV/SIGKILL, the job is sent a SIGXCPU signal which can be caught by the job and exit gracefully before it is killed. So if you need it, set ''s_vmem'' to a lower value than ''h_vmem'' and implement SIGXCPU handling and cleanup.
  
-Základní pravidlo, které musíme všichni ctít, aby SGE plnilo svou úlohu dobře: 
  
-  * Nespouštět úlohy ručně. (O ručně spuštěných úlohách SGE nemá informaci, klidně na daný uzel pošle ještě další úlohy z fronty.) +===== Advanced usage =====
-    * Interaktivní shell se dá získat příkazem ''qrsh'' (přičemž specifikujete požadavky na zdroje stejně jako u ''qsub'')+
  
-Další doporučení: +''qsub **-q** cpu-troja.q'' 
-  Pokud možno používat ''nice''+This way your job is submitted to the Troja queue. The default is ''cpu-ms.q''. You can also use e.g
-       Dotaz: jak se kombinuje ''nice'' ''qsub''em? SGE je snad nyní nastaveno tak, že vše bude nicenuté. Každopádně je dobré do submitovaného skriptu na začátek napsat ''renice 10 $$''+''-q '(troja*|ms*)''' to submit on any machine in those two queues (but **don't use ''-q '*'''** as this includes also [[:gpu|gpu.q]]), 
-  Uklízet po sobě lokální dataprotože jinak si tam už nikdo nic užitečného nepustí. +''-q '*@hector[14]''' to submit on hector1 or hector4
-  Vyhnout se hodně divokému paralelnímu přístupu ke sdíleným diskům. NFS server to pak nepěkně zpomalí pro všechny. Distribuujte tedy i data+''-q '[tm]*@!(hector*|iridium)''' to submit on any troja/ms machine except hectors and iridium
-  * Informovat SGE, kolik paměti úloha žereaby na strojích nedošla paměť (a používat "hard" limitkdy SGE úlohu zabije, pokud rezervovanou paměť překročí): <code>qsub -hard -l mem_free=8G -l act_mem_free=8G -l h_vmem=8G</code>+Howeverusually you should specify just the queue (cpu-troja.q vs. cpu-ms.q), not particular machineand 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).
  
-Víc pravidel není.+''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.
  
-===== Slušné chování =====+''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''.
  
-Pokud chci spouštět úlohykteré poběží dlouhou dobu (hodiny, dny), nepustím je všechny najednou, aby cluster mohli využívat i ostatní.+''qsub **-@** optionfile'' 
 +Instead of specifying all the ''qsub'' options on the command lineyou can store them in a file (you can use # comments in the file). See also [[#In-script options]].
  
-===== Triky opentlení =====+''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).
  
-==== ~bojar/tools/shell/qsubmit ====+''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.
  
-qsubmit je jako qsub, ale příjemnější:+''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.
  
-  nemusíte vyrábět skriptvyrobí ho sám (pozn.: nemusíte vyráběskriptkdyž použijete přepínač ''-b y''+''qsub **-now** y'' 
-  * nemusíte připisovat ''-cwd -j y -S /bin/bash''+Start the job immediately or not at alli.e. don'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'').
  
-<code> +''qsub **-N** my-name'' 
-~bojar/tools/shell/qsubmit "bashovy_prikaz < prismeruj > presmeruj 2> atd...+By default the name of a job (which you can see e.gin ''qstat'') is the name of the ''script.sh''. This way you can override it.
-</code> +
  
-lépe funguje ''~{stepanek,pajas}/bin/qcmd'' (nemusí se kvotovat parametrysprávně počítá čas běhu...)+''qsub **-S** /bin/bash'' 
 +The hashbang (''!#/bin/bash'') in your ''script.sh'' is ignoredbut you can change the interpreter with ''-S''I think ''/bin/bash'' is now (2017/09the default (but it used to be ''csh'').
  
-==== ~zeman/bin/qsub.csh ====+''qsub **-v** PATH[=value]'' 
 +Export a given environment variable from the current shell to the job.
  
-Podobná věc pro ''tcsh''Pokud bychom chtěli použít přesměrování standardního vstupu a výstupumusíme ho dát do uvozovek nebo apostrofů, protože jinak se o něm ''qsub.csh'' nedozví, do skriptu k odeslání to neopíše a naopak jeho standardní vstup a výstup bude přesměrovánV přesměrování i v případných dalších argumentech, kde se vyskytují cesty k souborům, je vhodné použít úplné cesty. Pozor také na to, aby šlo o soubory a složky viditelné z celé sítě (tedy ne ve vašem ''/mnt/h/tmp'', například).+''qsub **-V**'' 
 +Export all environment variables(This is not so needed nowwhen bash is the default interpreter and it seems your ''~/.bashrc'' is always sourced.)
  
-<code tcsh>setenv SCRIPTFILE /tmp/`basename $1`.$$.csh +''qsub **-soft** -l ... **-hard** -l ... -q ...'' 
-echo $> $SCRIPTFILE +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.
-echo $* +
-echo qsub -cwd --S /bin/tcsh -m e $SCRIPTFILE +
-qsub -cwd -V -S /bin/tcsh -m $SCRIPTFILE +
-qstat -'*' +
-rm $SCRIPTFILE</code>+
  
-Příklad spuštění:+''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.
  
-<code>qsub.csh $PARSER/train.pl "< $cesta/${xx}train.csts > $cesta/${xx}.1.stat"</code>+''**qalter**'' 
 +You can change some properties of already submitted jobs (both waiting in the queue and running). Changeable properties are listed in ''man qsub''.
  
-(Kdybych místo uvozovek použil apostrofy, nerozbalily by se mi proměnné. První argument (název skriptu) klidně mohl být v uvozovkách spolu s přesměrováním. Dal jsem ho ven jen proto, že potom ''qsub.csh'' podle něj pojmenuje job ve frontě.)+''**man** qsub qstat qalter qhold queue_conf sge_types complex'' 
 +Find out all the gory details which are missing hereYou'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).
  
-==== TectoMT: devel/tools/cluster_utils/qrunblocks ====+=== sshcwd === 
 +This is useful not only when sshing to sol machines. Add the following lines to your ''~/.bashrc''.
  
-Jako ''$BRUNBLOCKS'', ale spouští úlohy na gridu (bez pomoci [[internal:jtred]]u).+<code> 
 +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"; 
 +}
  
-   qrunblocks filelist blocks+# use WD to setup the working directory 
 +if [ -n "$WD" ]; then 
 +  echo "Autochanging dir to $WD" >&
 +  cd $WD; 
 +fi
  
-Skript zadanou hromádku souboru rozdělí do ''-''''-jobs'' jobůKaždý job na gridu pak projede své soubory danou sekvencí bloků.+alias sol1="sshcwd sol1.ufal.hide.ms.mff.cuni.cz" 
 +</code>
  
-Soubory možno zadat filelistem, nebo pomocí ''-''''-glob'' (stručně ''-g''). Bloky možno vyjmenovat v jednom argumentu, nebo načíst ze souboru pomocí ''--blocksfile SOUBOR''.+=== In-script options ===
  
-Je nutné buď zadat ''-''''-tmt-root CESTA'', nebo mít nastaven ''$TMT_ROOT'' podle inicializace TectoMT.+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.
  
-Parametr ''-E'' zpusobíže se jobům z aktuálního prostředí procedí všechny proměnné ''TMT_PARAM_*'' (čili např. model parseru ap.). Případně je pomocí ''-e'' možné vyjmenovat některé (další) ručně.+  #$ -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
  
-Parametr ''-''''-sync'' způsobí, že skript navíc bude (pasivně) čekat, až všechny joby skončí.+and you execute it now simply with ''qsub script.sh''.
  
-Výstup každého jobu jde do vlastního logu, ''JOBNAME.o123456''. Pokud JOBNAME nezadáte (parametr ''-N''), užije se defaultní ''qrunblocks''.+=== ~/.sge_request ===
  
-Parametr ''-''''-join'' způsobíže se STDOUT všech kousků (ve správném pořadí) sebere a vypíše na hlavní STDOUT (''-''''-join'' implikuje ''-''''-sync''). Při spojování se také dělá důkladný test exitstatusů, takže ''qrunblocks'' končí úspěchem jen tehdy, když všechny joby uspěly.+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).
  
-Bez ''-''''-sync'' nebo ''-''''-join'' nezbývá, než kontrolovat, jestli logy jednotlivých jobů na konci nemají napsáno:  ''Status: FAILED''.+=== Array jobs ===
  
-===== Monitorování úloh =====+If you have a set of tasks (of the same type) and want to run them on multiple machines, use ''qsub -t''
 +  * ''-t 1-n'' start array job with //n// tasks numbered //1 ... n// 
 +  * environmental variable ''SGE_TASK_ID'' 
 +  * output and error files ''$JOB_NAME.[eo]$JOB_ID.$TASK_ID'' 
 +  * ''-t m-n[:s]'' start array job with tasks //m, m + s, ..., n// 
 +  * environmental variables ''SGE_TASK_FIRST, SGE_TASK_LAST, SGE_TASK_STEPSIZE'' 
 +  * ''-tc j'' run at most //j// tasks simultaneously 
 +  * ''-hold_jid_ad comma_separated_job_list'' array jobs that must finish before this job starts; task //i// of the current job depends only on task //i// of the specified jobs
  
-  * ''qstat [-u user]'' -- seznam úloh aktuálně běžících / ve frontě +If you use ''-tc'', then SGE can handle array jobs of virtually any sizeIt only starts as many tasks as specified in ''-tc'' at any timeand each scheduling interval (15 seconds in our current configurationit starts new tasks if less than the specified ''-tc'' limit are running. Howevernote 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.
-  * ''qhost'' -- dostupné zdroje +
-  * ''/SGE/REPORTER/LRC-UFAL/bin/lrc_users_real_mem_usage -u user -w'' -- aktuální využití paměti uživatelem +
-  * ''/SGE/REPORTER/LRC-UFAL/bin/lrc_users_limits_requested -w'' -- nárokované požadavky uživatelů +
-  * ''/SGE/REPORTER/LRC-UFAL/bin/lrc_nodes_meminfo'' -- vypis vsech uzlu a stav vytiznosti pameti. +
-    * mem_total: celkova pamet uzlu +
-    * mem_free: tedy kolik je jeste volne pameti z pametove quoty uzlu +
-    * act_mem_free: kolik uzlu OPRAVDU zbyva volne pameti +
-    * mem_used: kolik je pameti skutecne pouzito +
-  * ''/SGE/REPORTER/LRC-UFAL/bin/lrc_state_overview'' -- celkový přehled o clusteru +
-    * celkovy pocet jaderpocet vyuzitych jader +
-    * celkova velikost RAM, kolik je ji fyzicky nepouzite, kolik je ji jeste nerezervovane +
-    * po jednotlivych uzivatelich (zrovna pocitajicich-- kolik jim bezi uloh, kolik jich maji ve fronte a kolik z nich je ve stavu hold +
-  * ''cat /SGE/REPORTER/LRC-UFAL/stats/userlist.weight'' -- seznam uživatelů clusteru seřazený podle dosavadní aktivity (počet odeslaných úloh × časkterý běžely), aktualizovaný každý den v&nbsp;noci +
-  * [[https://ufaladm2.ufal.hide.ms.mff.cuni.cz/munin/ufal.hide.ms.mff.cuni.cz/lrc1.ufal.hide.ms.mff.cuni.cz/lrc_users.html|Munin: graf vytíženosti clusteru podle uživatelů]] (viditelný pouze ze sítě ÚFAL)+
  
-===== Časté a záludné problémy =====+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}''.
  
-==== Submitnutý job může znovu submitovat ====+=== Ssh to random sol === 
 +Ondřej Bojar suggests to add the following alias to your .bashrc (cf. [[#sshcwd]]): 
 +<code>alias cluster='comp=$(( (RANDOM % 10) +1)); ssh -o "StrictHostKeyChecking no" sol$comp'</code>
  
-Danovy starší zkušenosti s clusterem PBS (nikoli SGE) říkaly, že tohle nejde. Ale jde to, aspoň u nás. Příkazy ''qsub'' a spol. jsou kromě hlavy clusteru dostupné i na všech strojích clusteru, samozřejmě pokud váš soubor ''.bashrc'', ''.cshrc'' apod. zajistí, že se i na nich provede inicializace prostředí SGE.+===== Job monitoring =====
  
 +  * ''qstat [-u user]'' -- print a list of running/waiting jobs of a given user
 +  * ''qhost'' -- print available/total resources
 +  * ''qacct -j job_id'' -- print info even for ended job (for which ''qstat -j job_id'' does not work). See ''man qacct'' for more.
  
 +  * ''/opt/LRC/REPORTER/LRC-UFAL/bin/lrc_users_real_mem_usage -u user -w'' -- current memory usage of a given user
 +  * ''/opt/LRC/REPORTER/LRC-UFAL/bin/lrc_users_limits_requested -w'' -- required resources of all users
 +  * ''/opt/LRC/REPORTER/LRC-UFAL/bin/lrc_nodes_meminfo'' -- memory usage of all nodes
 +    * mem_total:
 +    * mem_free: total memory minus reserved memory (using ''qsub -l mem_free'') for each node
 +    * act_mem_free: really free memory
 +    * mem_used: really used memory
 +  * ''/opt/LRC/REPORTER/LRC-UFAL/bin/lrc_state_overview'' -- overall summary (with per-user stats for users with running jobs)
 +  * ''cat /opt/LRC/REPORTER/LRC-UFAL/stats/userlist.weight'' -- all users sorted according to their activity (number of submitted jobs × their average duration), updated each night
  
-==== Proměnné prostředí, nastavení vlastního prostředí ====+  * [[https://ufaladm2.ufal.hide.ms.mff.cuni.cz/munin/ufal.hide.ms.mff.cuni.cz/lrc-master.ufal.hide.ms.mff.cuni.cz/index.html|Munin: graph of cluster usage by day and user]] and  [[https://ufaladm2.ufal.hide.ms.mff.cuni.cz/munin/ufal.hide.ms.mff.cuni.cz/nfs-core.ufal.hide.ms.mff.cuni.cz/index.html|Munin monitoring of disk storage]] (both accessible only from ÚFAL network)
  
-SGE spouští skripty v čistém prostředí. Nebuďte proto překvapenikdyž vám skript na konzoli poběží dobřeale po submitnutí fungovat nebudeTřeba nenašel potřebné programy v ''$PATH''+===== Profiling ===== 
 +As stated aboveyou should always specify the exact memory limits when running your tasksso that you neither waste RAM nor starve others of memory by using more than you requestedHowever, memory requirements can be difficult to estimate in advance. That's why you should profile your tasks first.
  
-Zatím nevím přesněkteré ze souborů ''.login''''.bashrc'' ap. SGE spouští, jestli vůbec nějaké. Naopak, experimentálně jsem ověřil, že ''qsub -S /bin/bash skript'' nenačte žádný z ''.bashrc'', ''.bash_profile'', ''.login''ani ''.profile''.+A simple method is to run the task and observe the memory usage reported in the epilogbut 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 setit defaults to ''flush_time'', which is preset to 15 secondsBut the kernel records all info immediately without pollingand you can view these exact stats by looking into /proc/$PID/status while the task is running.
  
-Z toho například také vyplýváže bez ošetření se jako **Java** používá+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 theseuse ''/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.
  
-   java version "1.5.0" +Obtaining peak usage of multiprocess applications is trickierDetached 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.
-   gij (GNU libgcj) version 4.1.2 20070502 (Red Hat 4.1.2-12)+
  
-Pokud chcete submittovaný program pouštět ve svém oblíbeném prostředí (např. nastavení ''PATH''), musíte v obalujícím skriptu příslušné ''.bash*'' načíst. Vždy je ale bezpečnější všude psát plné cesty, než spoléhat na PATH.+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.
  
-==== Jiný shell ====+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).
  
-Abych mohl poslat nějakou úlohu do fronty, musím pro ni vyrobit vlastní skript. Budiž, vyrobil jsem vlastní skript: 
- 
-<code> 
-#!/bin/bash 
-program > log.out 2> log.err 
-</code> 
- 
-Když tento skript spustím, stane se očekávané. Přesměrují se výstupy z daného programu do souborů a je to. 
- 
-Když takový skript submitnu, program se **nespustí**. V logu zjistím, že (standardní chybový) výstup shellu, který pouštěl můj skript praví kryptickou zprávu "Ambiguous redirect". 
- 
-Nebudu vás napínat, zde je vysvětlení: SGE ignoruje první řádek skriptu (ve skutečnosti je pravda horší, hledá v něm nějaké parametry pro sebe) a spouští skript v ''csh''. Rozdíl mezi bashem a csh se v primitivních skriptech na první pohled nepozná, pozná se až v konstrukci if-then-else, a také v přesměrovávání. csh nerozumí přesměrování ''2>'' 
- 
-Takto SGE přinutíte, aby použilo bash: 
- 
-<code> 
-  qsub -S /bin/bash skript 
-</code> 
- 
-Jinou možností je přesměrovat stderr a stdout pomocí syntaxe csh: 
- 
-<code> 
-( command >stdout_file ) >&stderr_file 
-</code> 
- 
- 
-==== bashrc a podobné nesmí nic vypisovat na konzoli ==== 
- 
-Opsáno z [[http://www.sara.nl/userinfo/lisa/usage/batch/index.html]]. 
- 
-It is important, that the files that are sourced during a login such as .bash_profile .profile .bashrc .login .cshrc don't produce any output when a non-interactive login is done. If they do, changes are that your job will run, but that the batch system is unable to deliver to you the standard output and error files. In that case the status of your job will be 'E' after the job is finished. Here is an example how you can test in a .bash_profile or .bashrc if this is an interactive login: 
  
 +===== Other =====
 +  * There is a **great course [[http://ufal.mff.cuni.cz/courses/npfl102|Data intensive computing]]**, see the 2016 handouts if you missed the course. It covers the usage of [[http://spark.apache.org/|Spark]] (MapReduce/Hadoop alternative, but better) and HDFS (Hadoop filesystem).
 +  * **Note:** some hadoop basics and a lot of NoSQL technologies are covered by [[https://is.cuni.cz/studium/predmety/index.php?do=predmet&kod=NDBI040|Big Data Management and NoSQL Databases]]
 +  * There is a special cluster for Mgr (and Bc) students (but not for PhD and UFAL members): http://aic.ufal.mff.cuni.cz/
 +  * You can use environment variables ''$JOB_ID'', ''$JOB_NAME''.
 +  * One job can submit other jobs (but be careful with recursive:-)). A job submitted to the CPU cluster may submit GPU jobs (to the ''qpu.q'' queue).
 +  * It is important, that the files that are sourced during a login such as .bash_profile, .profile, .bashrc, .login etc. don't produce any output when a non-interactive login is done. If they do, chances are that your job will run, but that the batch system is unable to deliver to you the standard output and error files. In that case the status of your job will be 'E' after the job is finished. Here is an example how you can test in a .bash_profile or .bashrc if this is an interactive login:
 <code> <code>
 unset INTERACTIVE unset INTERACTIVE
Line 259: Line 332:
 fi fi
 </code> </code>
 +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.
  
-==== Jak zjistit, jaké zdroje jsem pro svou úlohu požadoval ==== 
- 
-<code>qstat -j 973884,982737,984029,984030,984031,984034,984036 | grep resource 
-hard resource_list:         mem_free=50g 
-hard resource_list:         mem_free=200g 
-hard resource_list:         mem_free=16g 
-hard resource_list:         mem_free=16g 
-hard resource_list:         mem_free=16g 
-hard resource_list:         mem_free=31g</code> 
- 
-==== Jak rezervovat více jader na stejném stroji pro 1 job ==== 
- 
-<code> 
-qsub -pe smp <pocet jader> 
-</code> 
- 
-===== Synchronizace úloh (v Perlu) ===== 
- 
-Pokud chci paralelizovat část úlohy (zde ''muj_skript.pl''), obvykle potřebuju po provedení paralelní části posbírat výsledky a hlavně počkat na dokončení všech paralelních větví. Jak na to jednoduše: 
- 
-  * Obalím svůj skript pro běh na gridu – vytvořím ''obaleno.sh'': 
-    <code> 
-#!/bin/bash 
-. /net/projects/SGE/user/sge_profile >/dev/null 
- 
-qrsh -cwd -V -p -50 -l mf=5g -now no 'renice 10 $$ >/dev/null; ./muj_skript.pl $@' 
-</code> 
-  * Ve svém hlavním skriptu ho pak zavolám a posbírám výsledky: 
-    <code> 
-use FileHandle; 
-use IPC::Open2; 
-use threads; 
-use threads::shared; 
-my @threads; 
-my @results; 
-share(@results); 
-for (@inputs)   { 
-    my $t = async { 
-        my $reader; my $writer; 
-        my $pid = open2($reader, $writer, "./obaleno.sh " . $parametry); # Pustime ulohu na gridu 
-        die "Failed to open bipipe" if !$pid; 
-        $writer->autoflush(1); # Muzem zavolat, ale v gridu NEFUNGUJE!!! 
-        print $writer "$_\n" or die; # Poslem uloze v gridu vstup 
-        $writer->close(); # Dulezite, viz o 2 radky vyse 
-        for (<$reader>   { # Posbirame vysledky 
-            chomp; 
-            { 
-               lock @results; 
-               push @results, $_; 
-            } 
-        } 
-        waitpid $pid, 0; # Pockame s ukoncenim vlakna na ukonceni ulohy v gridu 
-        return $? >> 8; # Pokusime se ziskat navratovou hodnotu (netestoval jsem) 
-    }; 
-    push @threads, $t; 
-} 
-for (@threads)  { # Pockame, az to vsichni dodelaji 
-    die "Child exited with non-zero exit code" if $_->join(); 
-} 
-</code> 
- 
-Poznámky:  
-  * Pokud lze všechno předat parametry, nemusí se otevírat obousměrná roura a situace bude jednodušší 
-  * Pokud ''muj_skript.pl'' začne psát na výstup dřív, než přečetl všechen vstup, dojde k deadlocku. Lze vyřešit obalením příkazy ''cat'' v ''obaleno.sh''. 
-  * Celý příklad je k vidění v Czengu od V.N. 

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