Changes between Version 3 and Version 4 of en/UsingGPU


Ignore:
Timestamp:
Oct 16, 2024, 1:34:29 PM (9 months ago)
Author:
Ales Horak
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • en/UsingGPU

    v3 v4  
    11= How to use GPUs on NLP Centre servers =
    22
     3[[PageOutline(2-3)]]
     4
    35The following servers have GPUs:
    4 * apollo - 13 GPUs, from 15 GB to 80 GB
    5 * ephimetheus1, ephimetheus2, ephimetheus3 and ephimetheus4 - each 2 GPUs with 15 GB
    6 * turnus03 and turnus03 - each one GPU with 11 GB
     6* `apollo` - 11 GPUs, from 15 GB to 80 GB
     7* `akeso` - 3 GPUs, from 15 GB to 45 GB
     8* `ephimetheus1`, `ephimetheus2`, `ephimetheus3` and `ephimetheus4` - each 2 GPUs with 15 GB
     9* `turnus03` and `turnus04` - each one GPU with 11 GB
    710
    811
    912Follow this actions:
    1013
     141. `ssh ...` to one of the servers (e.g. `ssh apollo`). If you are not currently inside the faculty network, you must [#vpn connect to the FI MUNI VPN] first.
     151. `cd /nlp/projekty/...` to your project directory
     161. setup !HuggingFace cache as detailed [#cache below]
    11171. find available GPUs: run `gpustat` or `nvidia-smi`
    12182. `export CUDA_DEVICE_ORDER=PCI_BUS_ID`
     
    1521   `export CUDA_VISIBLE_DEVICES=GID` where GID is the ID of the selected GPU (the first column in the `gpustat` or `nvidia-smi` listing).
    1622
     23== Connecting to a GPU server ==
     24==== [#vpn  Connecting to FI MUNI VPN ] ====
     25- Download the VPN configuration for FI MUNI from here: https://www.fi.muni.cz/tech/unix/vpn.html
     26- Use your faculty login `x.....` with your secondary password as the credentials
    1727
     28==== Connect to the server ====
     29* Run command (replace `...` with the server name followed by a dot `.`):
     30{{{
     31ssh xsurname@....fi.muni.cz
     32}}}
     33* Type in the secondary password again
    1834
    19 = Running jupyter notebook on Apollo (Linux) =
     35== [#cache Change the cache location of HuggingFace Datasets] ==
     36* You need to change the download location of datasets. The default location is in your home and it can easily get full
     37* prepare a cache directory in your project
     38{{{
     39mkdir /nlp/projekty/.../hf_cache
     40}}}
     41* To change the HF Datasets location run:
     42{{{
     43export HF_DATASETS_CACHE="/nlp/projekty/.../hf_cache"
     44}}}
     45* To make this change permanent so you don't need to type it every time you enter the server, add it to your `.bashrc` file in your home directory
    2046
    21 This is a tutorial on how to run a Jupyter interface on apollo server.
    22 
    23 == Connecting to apollo server ==
    24 ==== Connecting to FI MUNI VPN ====
    25 - Download VPN configuration for FI MUNI here: https://www.fi.muni.cz/tech/unix/vpn.html.cs
    26 - As login use facilty credentials (xsurname and secondary password)
    27 ==== Connecting to server ====
    28 * Run command:
     47== Create virtual environment for your project ==
    2948{{{
    30 ssh xsurname@apollo.fi.muni.cz
    31 }}}
    32 * Type in secondary password
    33 
    34 == Run Jupyter notebook with virtual env ==
    35 ==== Create virtual env and run it ====
    36 {{{
     49ssh ... # to the server
     50cd /nlp/projekty/...  # your project
    3751virtualenv myenv
    3852source myenv/bin/activate
    3953}}}
     54This `myenv` activation must be done before any package is installed via `pip`/`pip3` or the `python`/`python3` command is run with your program.
     55
     56Alternatively, you may run these commands with full path to your `myenv` and its `bin` subdirectory:
     57{{{
     58/nlp/projekty/.../myenv/bin/pip install ...
     59/nlp/projekty/.../myenv/bin/python my_program.py
     60}}}
     61
     62The created environment may be dependent on the exact server setup and possibly may not work well at another server.
     63
     64== Run jupyter notebook on a GPU server ==
     65
    4066==== Connect your virtual env with the Jupyter notebook ====
     67* after activating your `myenv` environment install `ipykernel`
    4168{{{
    4269pip install ipykernel
    4370python -m ipykernel install --user --name=myenv
    4471}}}
    45 You should get the output:
     72 You should get the output:
    4673{{{
    4774Installed kernelspec myenv in /home/user/.local/share/jupyter/kernels/myenv
     
    5683jupyter notebook --no-browser --port 2222
    5784}}}
    58 ==== Create SSH Tunnelling ====
     85The output should contain one line in the form
     86{{{
     87http://localhost:2222/?token=...
     88}}}
     89You will use it later, after setting up an SSH tunnel.
     90
     91==== [#ssh Create SSH Tunnelling] ====
    5992* Open new second terminal and insert the following command
    6093{{{
    6194ssh xsurname@apollo.fi.muni.cz -NL 2222:localhost:2222
    6295}}}
    63 The second port must match the port selected when starting the jupyter notebook
     96 The second port must match the port selected when starting the jupyter notebook
    6497
    65 ==== Open Jupyter notebook on local machine ====
    66 * Type in browser:
    67 {{{
    68 localhost:2222
    69 }}}
    70 Again this port must match the first port in ssh tunelling step
    71 * Log  into the Jupyter notebook
    72 * To get the token type:
    73 {{{
     98==== Open Jupyter notebook on the local machine ====
     99* Point your browser to a the previously obtained address of the notebook
     100  http://localhost:2222?token=... [[br]]
     101  If you have used the same port numbers, as we do, you do not need to change anything in the URL.
     102  Otherwise, the port must match the first port in the [#ssh ssh tunelling] step.
     103* If you have correctly copied the `token`, then you are logged in.
     104  Otherwise, to get the token again run:
     105  {{{
     106ssh ... # the server
    74107jupyter notebook list
    75108}}}
    76 * Copy the token part and either create a password or log in with the token itself
     109  Copy the jupyter notebook URL and open it in your local browser.
    77110
    78 == Change the cache location of !HuggingFace Datasets ==
    79 * You need to change the download location of datasets. The default location is in your home and it can easly get full
    80 * To change to Dataset location type:
    81 {{{
    82 export HF_DATASETS_CACHE="/path/to/another/directory"
    83 }}}
    84 * To make this change permanent so you don't need to type it every time you enter apollo add it to your .bashrc file at your home directory
    85 
     111  The notebook is opened with listing the directory of your project.
    86112
    87113== References used ==