Changes between Version 3 and Version 4 of en/UsingGPU
- Timestamp:
- Oct 16, 2024, 1:34:29 PM (9 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
en/UsingGPU
v3 v4 1 1 = How to use GPUs on NLP Centre servers = 2 2 3 [[PageOutline(2-3)]] 4 3 5 The 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 7 10 8 11 9 12 Follow this actions: 10 13 14 1. `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. 15 1. `cd /nlp/projekty/...` to your project directory 16 1. setup !HuggingFace cache as detailed [#cache below] 11 17 1. find available GPUs: run `gpustat` or `nvidia-smi` 12 18 2. `export CUDA_DEVICE_ORDER=PCI_BUS_ID` … … 15 21 `export CUDA_VISIBLE_DEVICES=GID` where GID is the ID of the selected GPU (the first column in the `gpustat` or `nvidia-smi` listing). 16 22 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 17 27 28 ==== Connect to the server ==== 29 * Run command (replace `...` with the server name followed by a dot `.`): 30 {{{ 31 ssh xsurname@....fi.muni.cz 32 }}} 33 * Type in the secondary password again 18 34 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 {{{ 39 mkdir /nlp/projekty/.../hf_cache 40 }}} 41 * To change the HF Datasets location run: 42 {{{ 43 export 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 20 46 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 == 29 48 {{{ 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 {{{ 49 ssh ... # to the server 50 cd /nlp/projekty/... # your project 37 51 virtualenv myenv 38 52 source myenv/bin/activate 39 53 }}} 54 This `myenv` activation must be done before any package is installed via `pip`/`pip3` or the `python`/`python3` command is run with your program. 55 56 Alternatively, 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 62 The 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 40 66 ==== Connect your virtual env with the Jupyter notebook ==== 67 * after activating your `myenv` environment install `ipykernel` 41 68 {{{ 42 69 pip install ipykernel 43 70 python -m ipykernel install --user --name=myenv 44 71 }}} 45 You should get the output:72 You should get the output: 46 73 {{{ 47 74 Installed kernelspec myenv in /home/user/.local/share/jupyter/kernels/myenv … … 56 83 jupyter notebook --no-browser --port 2222 57 84 }}} 58 ==== Create SSH Tunnelling ==== 85 The output should contain one line in the form 86 {{{ 87 http://localhost:2222/?token=... 88 }}} 89 You will use it later, after setting up an SSH tunnel. 90 91 ==== [#ssh Create SSH Tunnelling] ==== 59 92 * Open new second terminal and insert the following command 60 93 {{{ 61 94 ssh xsurname@apollo.fi.muni.cz -NL 2222:localhost:2222 62 95 }}} 63 The second port must match the port selected when starting the jupyter notebook96 The second port must match the port selected when starting the jupyter notebook 64 97 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 {{{ 106 ssh ... # the server 74 107 jupyter notebook list 75 108 }}} 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. 77 110 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. 86 112 87 113 == References used ==