[ 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
gpu [2016/04/27 16:45]
ufal
gpu [2024/10/02 15:21] (current)
popel
Line 1: Line 1:
 ====== GPU at ÚFAL ====== ====== GPU at ÚFAL ======
  
-This page summarizes which UFAL servers have some GPU card, and suggest basic diagnostic commands, paths to installed tools, etc., simply everything necessary at the very beginning of using GPU for experiments+This page summarizes which UFAL servers have some GPU card, and suggests basic diagnostic commands, paths to installed tools, etc., simply everything necessary at the very beginning of using GPUs for experiments
 + 
 +**TODO: IN 2022 MOVING FROM SGE TO SLURM** (see [[slurm|slurm guidelines]]) -- **commands like ''qsub'' and ''qstat'' will stop working!** 
 + 
 +**IN 2024: Newly, all the documentation is at a dedicated wiki https://ufal.mff.cuni.cz/lrc (you need to use ufal and [[internal:welcome-at-ufal#small-linguistic-password|small-linguistic password]] to access the wiki from outside of the UFAL network).***
  
 ===== Servers with GPU units ===== ===== Servers with GPU units =====
 +GPU cluster ''gpu-ms.q'' at Malá Strana:
  
-| machine | GPU                     | GPU RAM Cuda Theano TensorFlow Comment +| machine | GPU type | GPU driver version [[https://en.wikipedia.org/wiki/CUDA#GPUs_supported|cc]] GPU cnt GPU RAM (GB) | machine RAM (GB)
-titan-gpu |  2x GeForce GTX Titan 6 GB each    ?        ?              +dll1 |  Quadro RTX 5000   455.23.05 |  7.5   16  366.2 
-twister1 | ...has burnt           |  +dll3  NVIDIA RTX A4000 |   510.73.08 |  8.6 |  10 |  16 |  248.
-twister2 | GeForce GTX 570        |  1 GB   |   7.   ?        ?              +dll4  GeForce GTX 1080 Ti |   455.23.05 |  6.|  10 |  11 |  248.8 | 
-kronos   | ??                     ??      |      ?        ?      I don't have nvidia-smi in path |+| dll5 |  GeForce GTX 1080 Ti |   455.23.05 |  6.1 |  10 |  11 |  248.8 | 
 +| dll6 |  NVIDIA RTX A4000 |   510.73.08 |  8.6 |  8 |  16 |  248.8 | 
 +| dll7 |  NVIDIA RTX A4000 |   510.73.08  8.6  8 |  16 |  248.8 
 +dll8 |  Quadro RTX 5000 |   455.23.05  7.5  8 |  16 |  366.2 | 
 +| dll9 |  GeForce RTX 3090 |   455.23.05 |  8.6 |  4 |  25 |  183.0 | 
 +| dll10 |  GeForce RTX 3090 |   455.23.05  8.6  4 |  25 |  183.0 |
  
-===== Installed toolkits =====+GPU cluster ''gpu-troja.q'' at Troja:
  
-This should mention where each interesting toolkit lives (on a particular machine).+| machine | GPU type | GPU driver version | [[https://en.wikipedia.org/wiki/CUDA#GPUs_supported|cc]] | GPU cnt | GPU RAM (GB) | machine RAM (GB)
 +| tdll1 |  Quadro P5000 |   455.23.05 |  6.1 |  8 |  16 |  245.0 | 
 +| tdll2 |  Quadro P5000 |   455.23.05 |  6.1 |  8 |  16 |  245.0 | 
 +| tdll3 |  Quadro P5000 |   455.23.05 |  6.1 |  8 |  16 |  245.0 | 
 +| tdll4 |  Quadro P5000 |   455.23.05 |  6.1 |  8 |  16 |  245.0 | 
 +| tdll5 |  Quadro P5000 |   455.23.05 |  6.1 |  8 |  16 |  245.0 |
  
-===== Basic commands =====+Desktop machines: 
 +| machine                    | GPU type | [[https://en.wikipedia.org/wiki/CUDA#GPUs_supported|cc]] | GPUs | GPU RAM | Comment | 
 +| victoria; arc              | GeForce GT 630   | cc3.0 |  1 |  2 GB | desktop machine | 
 +| athena                     | GeForce GTX 1080 | cc6.1 |  1 |  8 GB | Tom's desktop machine | 
 + 
 +Multiple versions of CUDA library are accessible on each machine together with cudnn. Theano and TensorFlow is supported. 
 + 
 +[[http://ufaladm2.ufal.hide.ms.mff.cuni.cz/munin/ufal.hide.ms.mff.cuni.cz/lrc-master.ufal.hide.ms.mff.cuni.cz/index.html#dll|GPU usage rolling graphs]] 
 + 
 + 
 +===== Rules ===== 
 +  * First, read [[internal:Linux network]] and [[:Grid]]. 
 +  * All the rules from [[:Grid]] apply, even more strictly than for CPU because there are too many GPU users and not as many GPUs available. So as a reminder: always use GPUs via ''qsub'' (or ''qrsh''), never via ''ssh''. You can ssh to any machine e.g. to run ''nvidia-smi'' or ''htop'', but not to start computing on GPU. Don't forget to specify you RAM requirements with e.g. ''-l mem_free=8G,act_mem_free=8G,h_data=12G''
 +    * **Note that you need to use ''h_data'' instead of ''h_vmem'' for GPU jobs.** 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''
 +  * Always specify the number of GPU cards (e.g. ''gpu=1'') and your GPU memory requirements (e.g. ''gpu_ram=2G''). Thus e.g. <code>qsub -q 'gpu*' -l gpu=1,gpu_ram=2G</code> 
 +  * If you need more than one GPU card (on a single machine), always require at least as many CPU cores (''-pe smp X'') as many GPU cards you need. E.g. <code>qsub -q 'gpu*' -l gpu=4,gpu_ram=7G -pe smp 4</code> 
 +  * For interactive jobs, you can use ''qrsh'', but make sure to end your job as soon as you don't need the GPU (so don't use qrsh for long training). **Warning: ''-pty yes bash -l'' is necessary**, otherwise the variable ''$CUDA_VISIBLE_DEVICES'' will not be set correctly. E.g. <code>qrsh -q 'gpu*' -l gpu=1,gpu_ram=2G -pty yes bash -l</code>In general: don't reserve a GPU (as described above) without actually using it for longer time. (E.g. try separating steps which need GPU and steps which do not and execute those separately on our GPU resp. CPU cluster.) Ondřej Bojar has a script /home/bojar/tools/servers/watch_gpus for watching reserved but unused GPU on most machines which will e-mail you, but don't rely on it only. 
 +  * Note that the dll machines have typically 10 cards, but "just" 250 GB RAM (DLL7 has only 128 GB). So the expected (maximal) ''mem_free'' requirement for jobs with 1 GPU is 25GB. If your 1-GPU job takes e.g. 80 GB and you submit three such jobs on the same machine, you have effectively blocked the whole machine and seven GPUs remain unused. If you really need to submit more high-memory jobs, send each on a different machine. 
 +  * If you know an approximate runtime of your job, please specify it with ''-l s_rt=hh:mm:ss'' - this is a soft constraint so your job won't be killed if it runs longer than specified. It will help SGE to better schedule the jobs, especially multi-gpu reservations (see ''qconf -ssconf''). 
 + 
 + 
 +===== How to use cluster ===== 
 + 
 +==== Set-up CUDA and CUDNN ==== 
 + 
 +Multiple versions of ''cuda'' can be accessed in ''/opt/cuda''.  
 + 
 +You need to set library path from your ''~/.bashrc'': 
 + 
 +  CUDA_version=11.1 
 +  CUDNN_version=8.0 
 +  CUDA_DIR_OPT=/opt/cuda/$CUDA_version 
 +  if [ -d "$CUDA_DIR_OPT" ] ; then 
 +    CUDA_DIR=$CUDA_DIR_OPT 
 +    export CUDA_HOME=$CUDA_DIR 
 +    export THEANO_FLAGS="cuda.root=$CUDA_HOME,device=gpu,floatX=float32" 
 +    export PATH=$PATH:$CUDA_DIR/bin 
 +    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDA_DIR/cudnn/$CUDNN_version/lib64:$CUDA_DIR/lib64 
 +    export CPATH=$CUDA_DIR/cudnn/$CUDNN_version/include:$CPATH 
 +  fi 
 + 
 +  * When not using Theano, just Tensorflow this can be simplified to ''export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/cuda/10.1/lib64:/opt/cuda/11.1/cudnn/8.0/lib64''
 +  * Note that the ''cudnn'' library is compiled for specific version of ''cuda''. If you need specific version of ''cudnn'', you can look in ''/opt/cuda/$CUDA_version/cudnn/'' whether it is available for a given ''$CUDA_version''
 + 
 + 
 +==== TensorFlow Environment ==== 
 + 
 +Many people at UFAL use TensorFlow. To start using it it is recommended to create a [[python|Python virtual environment]] (or use Anaconda for it). Into the environment you must place TensorFlow. The TF is either in CPU or GPU version. 
 + 
 +  pip install tensorflow 
 +  pip install tensorflow-gpu 
 +   
 +You can use prepared environment by adding into your ~/.bashrc 
 + 
 +  export PATH=/a/merkur3/kocmanek/ANACONDA/bin:$PATH 
 + 
 +And then you can activate your environment: 
 + 
 +  source activate tf18 
 +  source activate tf18cpu 
 + 
 +This environment have TensorFlow 1.8.0 and all necessary requirements for NeuralMonkey. 
 + 
 +==== PyTorch Environment ==== 
 + 
 +Install PyTorch following the instructions on https://pytorch.org. 
 + 
 +At the time of writing, the recommended setup for CUDA 11.1 (supported by all GPU nodes) is: 
 + 
 +   pip3 install torch==1.10.0+cu111 torchvision==0.11.1+cu111 torchaudio==0.10.0+cu111 -f https://download.pytorch.org/whl/cu111/torch_stable.html 
 +==== Using cluster ==== 
 + 
 +As an alternative to ''qsub'', you can use /home/bojar/tools/shell/qsubmit 
 + 
 +  qsubmit --gpumem=2G --queue="gpu-ms.q" WHAT_SHOULD_BE_RUN 
 +   
 +It is recommended to use priority lower than the default -100 if you are not rushing for the results and don't need to leap over your colleagues jobs. Please, do not use priority between -99 to 0 for jobs taking longer than a few hours, unless it is absolutely necessary for your work. 
 +==== Basic commands ====
  
   lspci   lspci
Line 21: Line 113:
   nvidia-smi   nvidia-smi
     # more details, incl. running processes on the GPU     # more details, incl. running processes on the GPU
-    # ??? but where is nvidia-smi located, if not in /usr/bin/nvidia-smi+    # nvidia-* are typically located in /usr/bin 
 +  watch nvidia-smi 
 +    # For monitoring GPU activity in a separate terminal (thanks to Jindrich Libovicky for this!) 
 +    # You can also use nvidia-smi -l TIME
   nvcc --version   nvcc --version
     # this should tell CUDA version     # this should tell CUDA version
-    # ??? but where is it located once CUDA is installed? +    # nvcc is typically installed in /usr/local/cuda/bin/ 
-   +  theano-test 
 +    # dela to vubec neco uzitecneho? :-) 
 +    # theano-* are typically located in /usr/local/bin/ 
 +  /usr/local/cuda/samples/1_Utilities/deviceQuery/deviceQuery 
 +    # shows CUDA capability etc. 
 +  ssh dll1; ~popel/bin/gpu_allocations 
 +    # who occupies which card on a given machine 
 +     
 +=== Select GPU device === 
 + 
 +The variable CUDA_VISIBLE_DEVICES constrains tensorflow and other toolkits to compute only on the selected GPUs. **Do not set this variable yourself** (unless debugging SGE), it is set for you automatically by SGE if you ask for some GPUs (see above). 
 + 
 +To list available devices, use: 
 +  /opt/cuda/samples/1_Utilities/deviceQuery/deviceQuery | grep ^Device 
 + 
 +===== Performance tests ===== 
 + 
 +* [[http://www.trustedreviews.com/nvidia-geforce-gtx-1080-review-performance-benchmarks-and-conclusion-page-2| 980 vs 1080 vs Titan X (not the Titan Z we have)]] 
 + 
 +In the following table is the experiment conducted by Tom Kocmi. You can replicate experiment: /a/merkur3/kocmanek/Projects/GPUBenchmark (you will need to prepare environment of TensorFlow11 or use my ANACONDA). The benchmark uses 2GB model of seq2seq machine translation in Neural Monkey (De > EN). If not specified, the benchmark had an access only to one GPU. 
 + 
 +| machine | Setup; CPU/GPU; [[https://en.wikipedia.org/wiki/CUDA#Supported_GPUs|Capability]] [cc] | Walltime | Note | 
 +| athena     | GeForce GTX 1080; cc6.1            |    9:55:58 | Tom's desktop 
 +| dll2       | GeForce GTX 1080; cc6.1            |   10:19:40 |  | 
 +| titan      | GeForce GTX 1080 Ti                |   10:45:11 | (new result with correct CUDA version) | 
 +| dll1       | (2 GPU) GeForce GTX 1080; cc6.1    |   12:34:34 | Probably only one GPU was used | 
 +| twister2   | Quadro P5000                         13:19:00 |  | 
 +| dll2       | GeForce GTX 1080; cc6.1            |   13:01:05 | Only one GPU was used | 
 +| titan-gpu  | (2 GPU) GeForce GTX Titan Z; cc3.5 |   16:05:24 | Probably only one GPU was used | 
 +| kronos-dev | Tesla K40c; cc3.5                  |   22:41:01 |  | 
 +| twister2   | Tesla K40c; cc3.5                  |   22:43:10 |  | 
 +| twister1   | Tesla K40c; cc3.5                  |   24:19:45 |  | 
 +| helena1    | 16x cores CPU                      |   46:33:14 |  | 
 +| belzebub   | 16x cores CPU                      |   52:36:56 |  | 
 +| iridium    | Quadro K2000; cc3.0                |   59:47:58 |  | 
 +| helena7    | 8x cores CPU                         60:39:17 |  | 
 +| arc        | GeForce GT 630; cc3.0              |  103:42:30 | (approximated after 66 hours) | 
 +| lucifer4   | 8x cores CPU                        134:41:22 |  | 
 + 
 + 
 +=== Second Benchmark === 
 + 
 +The previous benchmark only compares the speed of processing units within the GPUs and do not take into account the size of memory. Therefore I have conducted another benchmark, this time for each graphic card I have increased the batch size as much as possible so the model still could fit into the GPU (the previous benchmark model had batch size 20). This way the results should be more representative of the power for each GPU. 
 + 
 +| GPU; Cuda capability       | GPU RAM |  Walltime | Batch size | Machine   | 
 +| GeForce GTX 1080 Ti; cc6.1 |   11 GB |  00:55:56 |       2300 | dll5      | 
 +| GeForce GTX 1080; cc6.1    |    8 GB |  01:10:57 |       1700 | dll1      | 
 +| Quadro P5000                 16 GB |  01:17:00 |       3400 | twister2 
 +| GeForce GTX Titan Z; cc3.5 |    6 GB |  02:20:47 |       1100 | titan-gpu | 
 +| Quadro K2000; cc3.0        |    2 GB |  28:15:26 |         50 | iridium   | 
 + 
 +===== Links ===== 
 + 
 +  * [[https://en.wikipedia.org/wiki/CUDA#Supported_GPUs|CUDA Supported GPUs (Wikipedia table of Compute Capability)]] 
 + 
 + 
 +GPU specs for those GPUs we have: 
 +  * [[http://www.nvidia.com/content/PDF/kepler/Tesla-K40-Active-Board-Spec-BD-06949-001_v03.pdf|Tesla K40c]] 
 + 
 +==== Individual acquisitions: NVIDIA Academic Hardware Grants ==== 
 + 
 +There is an easy way to get one high-end GPU: [[https://developer.nvidia.com/academic_gpu_seeding|ask NVIDIA for an Academic Hardware Grant]]. All it takes is writing a short grant application (at most ~2 hrs of work from scratch; if you have a GAUK, ~15 minutes of copy-pasting). Due to the GPU housing issues (mainly rack space and cooling), Milan F. said we should request the Tesla-line cards (2017; check with Milan about this issue). If you want to have a look at an application, feel free to ask at hajicj@ufal.mff.cuni.cz :) 
 + 
 +Take care, however, to coordinate the grant applications a little, so that not too many arrive from UFAL within a short time: these grants are explicitly //not// intended to build GPU clusters, they are "seeding" grants meant for researchers to try out GPUs (and fall in love with them, and buy a cluster later). If you are planning to submit the hardware grant, have submitted one, or have already been awarded one, please add yourself here. 
 + 
 +Known NVIDIA Academic Hardware Grants: 
 + 
 +  * Ondřej Plátek - granted (2015) 
 +  * Jan Hajič jr. - granted (early 2016) 
 + 
 + 

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