This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
guide:tensorflow [2020/09/08 16:26] kevin created |
guide:tensorflow [2025/04/23 14:19] (current) kevin |
||
|---|---|---|---|
| Line 3: | Line 3: | ||
| If you are making use of Jupyter notebook to write your python scripts then you first need to make sure you export the .py file from Jupyter and then copy it onto the cluster | If you are making use of Jupyter notebook to write your python scripts then you first need to make sure you export the .py file from Jupyter and then copy it onto the cluster | ||
| - | Also ensure job is copied to / | + | Also ensure job is copied to '' |
| ===== Running Tensorflow on CPU nodes ===== | ===== Running Tensorflow on CPU nodes ===== | ||
| Line 16: | Line 16: | ||
| | | ||
| - | Then | + | Then '' |
| - | + | ||
| - | cd /mnt/lustre/ | + | |
| Finally run | Finally run | ||
| Line 32: | Line 30: | ||
| | | ||
| | | ||
| + | |||
| ===== Running Tensorflow on GPU nodes ===== | ===== Running Tensorflow on GPU nodes ===== | ||
| As with CPU version you can test your python jobs on an interactive node: | As with CPU version you can test your python jobs on an interactive node: | ||
| - | qsub -I -P YOURPROGRAMME(E.G. CSCI1234) -q gpu_1 -l select=1: | + | qsub -I -P YOURPROGRAMME(E.G. CSCI1234) -q gpu_1 -l select=1: |
| Once on an interactive node (gpuNNNN) you need to load up appropriate modules: | Once on an interactive node (gpuNNNN) you need to load up appropriate modules: | ||
| | | ||
| - | module load chpc/ | + | |
| - | module load chpc/ | + | |
| - | Then | + | To test that Python (and Tensorflow) sees the GPUs: |
| - | cd /mnt/lustre/ | + | < |
| + | module purge | ||
| + | module load chpc/ | ||
| + | module load chpc/ | ||
| + | python3 | ||
| + | import tensorflow as tf | ||
| + | print(" | ||
| + | </ | ||
| + | |||
| + | > From the [[https:// | ||
| + | |||
| + | The output will look something like this: | ||
| + | < | ||
| + | 2020-11-03 18: | ||
| + | 2020-11-03 18: | ||
| + | name: Tesla V100-PCIE-32GB major: 7 minor: 0 memoryClockRate(GHz): | ||
| + | pciBusID: 0000: | ||
| + | 2020-11-03 18: | ||
| + | name: Tesla V100-PCIE-32GB major: 7 minor: 0 memoryClockRate(GHz): | ||
| + | pciBusID: 0000: | ||
| + | 2020-11-03 18: | ||
| + | name: Tesla V100-PCIE-32GB major: 7 minor: 0 memoryClockRate(GHz): | ||
| + | pciBusID: 0000: | ||
| + | 2020-11-03 18: | ||
| + | 2020-11-03 18: | ||
| + | 2020-11-03 18: | ||
| + | 2020-11-03 18: | ||
| + | 2020-11-03 18: | ||
| + | 2020-11-03 18: | ||
| + | 2020-11-03 18: | ||
| + | 2020-11-03 18: | ||
| + | Num GPUs Available: | ||
| + | >>> | ||
| + | </ | ||
| + | |||
| + | |||
| + | > Type '' | ||
| + | |||
| + | Now you can try your Python code: | ||
| + | |||
| + | cd /mnt/lustre3p/ | ||
| When running on a single GPU you need to include the following in your .py file to ensure that not all the CPU's on the node get consumed, thereby resulting in your job being killed by the scheduler | When running on a single GPU you need to include the following in your .py file to ensure that not all the CPU's on the node get consumed, thereby resulting in your job being killed by the scheduler | ||
| Line 60: | Line 98: | ||
| Once you are on the login node just type: | Once you are on the login node just type: | ||
| + | |||
| + | **module purge** | ||
| + | |||
| + | **module load chpc/ | ||
| **qtensorflow_cpu** (CPU version of Tensorflow) | **qtensorflow_cpu** (CPU version of Tensorflow) | ||
| Line 97: | Line 139: | ||
| Please take note of empty space in EXAMPLE2. This corresponds to the enter key | Please take note of empty space in EXAMPLE2. This corresponds to the enter key | ||
| + | ===== Updating Tensorflow on GPU nodes ===== | ||
| + | First get onto a GPU node: | ||
| + | |||
| + | qsub -I -P YOURPROGRAMME(E.G. CSCI1234) -q gpu_1 -l select=1: | ||
| + | |||
| + | To update tensorflow you should use a conda environment | ||
| + | |||
| + | module purge | ||
| + | module load chpc/ | ||
| + | |||
| + | Create your environment | ||
| + | |||
| + | conda create -n tf-gpu tensorflow-gpu python=3.8 | ||
| + | conda activate tf-gpu | ||
| + | |||
| + | The above only needs to be done once thereafter all you will need to do is: | ||
| + | module purge | ||
| + | module load chpc/ | ||
| + | conda activate tf-gpu | ||
| + | |||
| + | in order to use your updated version of tensorflow | ||