Skip to content

Commit b16fe07

Browse files
committed
finished first pass on tensorflow page
1 parent 277a747 commit b16fe07

2 files changed

Lines changed: 15 additions & 23 deletions

File tree

docs/hpc/08_ml_ai_hpc/04_tensorflow.md

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -176,26 +176,27 @@ Below is a sample Slurm script:
176176
#SBATCH --mem=64G # total memory per node (4G per cpu-core is default)
177177
#SBATCH --gres=gpu:2 # number of gpus per node
178178
#SBATCH --time=00:20:00 # total run time limit (HH:MM:SS)
179-
#SBATCH --mail-type=begin # send email when job begins
180-
#SBATCH --mail-type=end # send email when job ends
181-
#SBATCH --mail-user=<YourNetID>@princeton.edu
182179

183180
module purge
184-
module load anaconda3/2021.11
185-
conda activate tf2-v100
186181

187-
python cassava_classify.py --batch-size-per-replica=32 --epochs=15
182+
srun singularity exec --nv \
183+
--overlay /scratch/NetID/pytorch_examples_new/tensorflow-example/tensorflow.ext3:ro \
184+
/scratch/work/public/singularity/cuda12.1.1-cudnn8.9.0-devel-ubuntu22.04.2.sif\
185+
/bin/bash -c "source /ext3/env.sh; python mnist_classify.py --batch-size-per-replica=32 --epochs=15"
188186
```
187+
:::note
188+
Be sure to change `NetID` in the above scipt to your NetID.
189+
:::
189190

190-
Note that `srun` is not called and there is only one task. Submit the job as follows:
191+
Submit the job as follows:
191192

192-
```
193-
(tf2-v100) $ sbatch job.slurm
193+
```bash
194+
[NetID@log-1 tensorflow_example]$ sbatch job.slurm
194195
```
195196

196197
### Performance
197198

198-
The training time is shown below for different choices of `cpus-per-task` and the number of GPUs:
199+
The training time is shown below for different choices of `cpus-per-task` and the number of GPUs on a test system (your results will vary depending on your system specs):
199200

200201
| nodes | ntasks | cpus-per-task | GPUs | Training Time (s) | Mean GPU Utilization (%) |
201202
|:-------------:|:-------------:|:------------:|:--------:|:-----------------:|:-------------------------:|
@@ -218,21 +219,12 @@ The training time is shown below for different choices of `cpus-per-task` and th
218219

219220
The figure below shows the speed-up as a function of the number of GPUs. The dashed line shows the maximum possible speed-up.
220221

221-
<img src="speedup_vs_gpus.png" alt="speed-up" width="700"/>
222+
![speedup vs gpus plot](./static/speedup_vs_gpus.png)
222223

223224
We see that linear scaling is not observed. That is, the training time when using 2 GPUs is not 1/2 of the training time when using one. To improve on this one would profile the script and identify the performance bottleneck. Some of the training images are 500 pixels wide. It could be that the preprocessing step is the slowest.
224225

225-
All runs were done on adroit-h11g1 while making certain that no other jobs were running on the node:
226-
227-
```
228-
#SBATCH --mem=770000M
229-
#SBATCH --nodelist=adroit-h11g1
230-
```
231-
232226
## Multi-node Training
233227

234-
Look to [MultiWorkerMirroredStrategy](https://www.tensorflow.org/guide/distributed_training#multiworkermirroredstrategy) for using the GPUs on more than one compute node. There is an example for the [Keras API](https://www.tensorflow.org/tutorials/distribute/multi_worker_with_keras). Consider using Horovod instead of this approach (see below).
235-
236-
## Horovod
237-
238-
[Horovod](https://horovod.ai/) is a distributed deep learning training framework for TensorFlow, Keras, PyTorch, and Apache MXNet. It is based on MPI.
228+
- [MultiWorkerMirroredStrategy](https://www.tensorflow.org/guide/distributed_training#multiworkermirroredstrategy) for using the GPUs on more than one compute node.
229+
- [Keras API](https://www.tensorflow.org/tutorials/distribute/multi_worker_with_keras).
230+
- [Horovod](https://horovod.ai/) is a distributed deep learning training framework for TensorFlow, Keras, PyTorch, and Apache MXNet. It is based on MPI.
39.5 KB
Loading

0 commit comments

Comments
 (0)