| 1 | = How to use GPUs on NLP Centre servers = |
| 2 | |
| 3 | The following servers have GPUs: |
| 4 | * apollo |
| 5 | * ephimetheusX |
| 6 | |
| 7 | |
| 8 | |
| 9 | 1. find available GPUs: run `gpustat` or `nvidia-smi` |
| 10 | 2. `export CUDA_DEVICE_ORDER=PCI_BUS_ID` |
| 11 | 3. choose a GPU with no running processes |
| 12 | 4. limit your process to only selected GPU: |
| 13 | `export CUDA_VISIBLE_DEVICES=GID` where GID is the ID of the selected GPU (the first column in the `gpustat` or `nvidia-smi` listing). |
| 14 | |
| 15 | |
| 16 | |
| 17 | = Running jupyter notebook on Apollo (Linux) = |
| 18 | |
| 19 | This is a tutorial on how to run a Jupyter interface on apollo server. |
| 20 | |
| 21 | == Connecting to apollo server == |
| 22 | ==== Connecting to FI MUNI VPN ==== |
| 23 | - Download VPN configuration for FI MUNI here: https://www.fi.muni.cz/tech/unix/vpn.html.cs |
| 24 | - As login use facilty credentials (xsurname and secondary password) |
| 25 | ==== Connecting to server ==== |
| 26 | * Run command: |
| 27 | {{{ |
| 28 | ssh xsurname@apollo.fi.muni.cz |
| 29 | }}} |
| 30 | * Type in secondary password |
| 31 | |
| 32 | == Run Jupyter notebook with virtual env == |
| 33 | ==== Create virtual env and run it ==== |
| 34 | {{{ |
| 35 | virtualenv myenv |
| 36 | source myenv/bin/activate |
| 37 | }}} |
| 38 | ==== Connect your virtual env with the Jupyter notebook ==== |
| 39 | {{{ |
| 40 | pip install ipykernel |
| 41 | python -m ipykernel install --user --name=myenv |
| 42 | }}} |
| 43 | You should get the output: |
| 44 | {{{ |
| 45 | Installed kernelspec myenv in /home/user/.local/share/jupyter/kernels/myenv |
| 46 | }}} |
| 47 | * To check all your connected venvs |
| 48 | {{{ |
| 49 | jupyter kernelspec list |
| 50 | }}} |
| 51 | |
| 52 | ==== Run Jupyter notebook on a personally selected port ==== |
| 53 | {{{ |
| 54 | jupyter notebook --no-browser --port 2222 |
| 55 | }}} |
| 56 | ==== Create SSH Tunnelling ==== |
| 57 | * Open new second terminal and insert the following command |
| 58 | {{{ |
| 59 | ssh xsurname@apollo.fi.muni.cz -NL 2222:localhost:2222 |
| 60 | }}} |
| 61 | The second port must match the port selected when starting the jupyter notebook |
| 62 | |
| 63 | ==== Open Jupyter notebook on local machine ==== |
| 64 | * Type in browser: |
| 65 | {{{ |
| 66 | localhost:2222 |
| 67 | }}} |
| 68 | Again this port must match the first port in ssh tunelling step |
| 69 | * Log into the Jupyter notebook |
| 70 | * To get the token type: |
| 71 | {{{ |
| 72 | jupyter notebook list |
| 73 | }}} |
| 74 | * Copy the token part and either create a password or log in with the token itself |
| 75 | |
| 76 | == Change the cache location of !HuggingFace Datasets == |
| 77 | * You need to change the download location of datasets. The default location is in your home and it can easly get full |
| 78 | * To change to Dataset location type: |
| 79 | {{{ |
| 80 | export HF_DATASETS_CACHE="/path/to/another/directory" |
| 81 | }}} |
| 82 | * 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 |
| 83 | |
| 84 | |
| 85 | == References used == |
| 86 | 1. SSH tunell: https://medium.com/@apbetahouse45/how-to-run-jupyter-notebooks-on-remote-server-part-1-ssh-a2be0232c533 |
| 87 | 2. FI MUNI VPN: https://www.fi.muni.cz/tech/unix/vpn.html.cs |
| 88 | 3. Jupyter notebook with virtualenv: https://janakiev.com/blog/jupyter-virtual-envs/ |
| 89 | 4. !HuggingFace dataset location change: https://huggingface.co/docs/datasets/v1.12.0/cache.html |
| 90 | |