-
Notifications
You must be signed in to change notification settings - Fork 989
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated torchrun instructions (#2096)
* Updated torchrun instructions * Update examples/README.md Co-authored-by: Benjamin Bossan <[email protected]> * Update examples/README.md Co-authored-by: Benjamin Bossan <[email protected]> * Update examples/README.md Co-authored-by: Benjamin Bossan <[email protected]> * Update examples/README.md Co-authored-by: Benjamin Bossan <[email protected]> * Update README.md for torchrun instructions * Added SLURM scripts and updated README * Update examples/Slurm/submit-multinode.sh Co-authored-by: Zach Mueller <[email protected]> * Update examples/Slurm/submit-multiGPU.sh Co-authored-by: Zach Mueller <[email protected]> * Update examples/README.md Co-authored-by: Zach Mueller <[email protected]> * Update examples/README.md Co-authored-by: Zach Mueller <[email protected]> * final details * modified argument parser * modified slurm multigpu script * modified multinode slurm script * Added accelerate multine issue * Update examples/README.md Co-authored-by: Zach Mueller <[email protected]> * fixed readme commnad * added --main_process_port specification to readme * Revert "modified argument parser" This reverts commit c3bef5c. --------- Co-authored-by: Benjamin Bossan <[email protected]> Co-authored-by: Zach Mueller <[email protected]>
- Loading branch information
1 parent
35b0206
commit 427ef8b
Showing
3 changed files
with
95 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
#SBATCH --job-name=multigpu | ||
#SBATCH -D . | ||
#SBATCH --output=O-%x.%j | ||
#SBATCH --error=E-%x.%j | ||
#SBATCH --nodes=1 | ||
#SBATCH --ntasks-per-node=1 # number of MP tasks | ||
#SBATCH --gres=gpu:4 # number of GPUs per node | ||
#SBATCH --cpus-per-task=160 # number of cores per tasks | ||
#SBATCH --time=01:59:00 # maximum execution time (HH:MM:SS) | ||
|
||
###################### | ||
### Set enviroment ### | ||
###################### | ||
source activateEnviroment.sh | ||
export GPUS_PER_NODE=4 | ||
###################### | ||
|
||
export SCRIPT=/accelerate/examples/complete_nlp_example.py | ||
export SCRIPT_ARGS=" \ | ||
--mixed_precision fp16 \ | ||
--output_dir /accelerate/examples/output \ | ||
--with_tracking \ | ||
" | ||
|
||
accelerate launch --num_processes $GPUS_PER_NODE $SCRIPT $SCRIPT_ARGS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
#SBATCH --job-name=multinode | ||
#SBATCH -D . | ||
#SBATCH --output=O-%x.%j | ||
#SBATCH --error=E-%x.%j | ||
#SBATCH --nodes=4 # number of nodes | ||
#SBATCH --ntasks-per-node=1 # number of MP tasks | ||
#SBATCH --gres=gpu:4 # number of GPUs per node | ||
#SBATCH --cpus-per-task=160 # number of cores per tasks | ||
#SBATCH --time=01:59:00 # maximum execution time (HH:MM:SS) | ||
|
||
###################### | ||
### Set enviroment ### | ||
###################### | ||
source activateEnviroment.sh | ||
export GPUS_PER_NODE=4 | ||
###################### | ||
|
||
###################### | ||
#### Set network ##### | ||
###################### | ||
head_node_ip=$(scontrol show hostnames $SLURM_JOB_NODELIST | head -n 1) | ||
###################### | ||
|
||
export LAUNCHER="accelerate launch \ | ||
--num_processes $((SLURM_NNODES * GPUS_PER_NODE)) \ | ||
--num_machines $SLURM_NNODES \ | ||
--rdzv_backend c10d \ | ||
--main_process_ip $head_node_ip \ | ||
--main_process_port 29500 \ | ||
" | ||
export SCRIPT="/accelerate/examples/complete_nlp_example.py" | ||
export SCRIPT_ARGS=" \ | ||
--mixed_precision fp16 \ | ||
--output_dir /accelerate/examples/output \ | ||
" | ||
|
||
# This step is necessary because accelerate launch does not handle multiline arguments properly | ||
export CMD="$LAUNCHER $PYTHON_FILE $ARGS" | ||
srun $CMD |