-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from NAG-DevOps/python-example
Refactor pytorch-multicpu to be use-ready in a subdirectory
- Loading branch information
Showing
4 changed files
with
62 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!-- TOC --><a name="README"></a> | ||
# README | ||
|
||
This directory has example scripts to using Pytorch with Python virtual environment to run on multiple CPUs (most universal). | ||
Adapted to SPEED from https://docs.alliancecan.ca/wiki/PyTorch | ||
|
||
``` | ||
(speed-submit) | ||
cd /speed-scratch/$USER | ||
salloc -p ps --mem=20G --mail-type=ALL | ||
(compute node) | ||
time ./firsttime.sh | ||
(takes about 5 mins) | ||
exit | ||
(speed-submit) | ||
sbatch -p ps pytorch-multicpu.sh | ||
tail -f EXECUTIONHOST-JOBID.out | ||
``` |
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,16 @@ | ||
#!/encs/bin/tcsh | ||
|
||
#### Virtual ENV creation. One time only. | ||
#### Run after salloc to a compute node! | ||
|
||
cd /speed-scratch/$USER | ||
module load python/3.9.18/default | ||
setenv TMP /speed-scratch/$USER/tmp | ||
setenv TMPDIR /speed-scratch/$USER/tmp | ||
python -m venv $TMPDIR/pytorchcpu | ||
source $TMPDIR/pytorchcpu/bin/activate.csh | ||
pip install torch torchvision | ||
pip install urllib3==1.26.6 | ||
deactivate | ||
|
||
#### END of VEnv creation |
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,18 @@ | ||
#!/encs/bin/tcsh | ||
|
||
#SBATCH --nodes 1 | ||
#SBATCH --tasks-per-node=1 | ||
#SBATCH --cpus-per-task=4 # change this parameter to 2,4,6,... to see the effect on performance | ||
|
||
#SBATCH --mem=24G | ||
#SBATCH --time=0:05:00 | ||
#SBATCH --output=%N-%j.out | ||
|
||
#SBATCH --mail-type=ALL | ||
|
||
source /speed-scratch/$USER/tmp/pytorchcpu/bin/activate.csh | ||
echo "starting training..." | ||
|
||
time srun python torch-multicpu.py | ||
|
||
# EOF |
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