1010# to pip install dependencies (other than pytorch), run all examples, and remove temporary/changed data files.
1111# Expects pytorch, torchvision to be installed.
1212
13- BASE_DIR=` pwd` " /" ` dirname $0 `
14- EXAMPLES=` echo $1 | sed -e ' s/ //g' `
15-
16- # Redirect 'python' calls to 'python3'
17- python () {
18- command python3 " $@ "
19- }
13+ BASE_DIR=" $( pwd) /$( dirname $0 ) "
14+ source $BASE_DIR /utils.sh
2015
2116USE_CUDA=$( python -c " import torchvision, torch; print(torch.cuda.is_available())" )
2217case $USE_CUDA in
@@ -35,43 +30,11 @@ case $USE_CUDA in
3530 ;;
3631esac
3732
38- ERRORS=" "
39-
40- function error() {
41- ERR=$1
42- ERRORS=" $ERRORS \n$ERR "
43- echo $ERR
44- }
45-
46- function install_deps() {
47- echo " installing requirements"
48- cat $BASE_DIR /* /requirements.txt | \
49- sort -u | \
50- # testing the installed version of torch, so don't pip install it.
51- grep -vE ' ^torch$' | \
52- pip install -r /dev/stdin || \
53- { error " failed to install dependencies" ; exit 1; }
54- }
55-
56- function start() {
57- EXAMPLE=${FUNCNAME[1]}
58- cd $BASE_DIR /$EXAMPLE
59- echo " Running example: $EXAMPLE "
60- }
61-
6233function dcgan() {
6334 start
6435 python main.py --dataset fake $CUDA_FLAG --mps --dry-run || error " dcgan failed"
6536}
6637
67- function distributed() {
68- start
69- python tensor_parallelism/tensor_parallel_example.py || error " tensor parallel example failed"
70- python tensor_parallelism/sequence_parallel_example.py || error " sequence parallel example failed"
71- python tensor_parallelism/fsdp_tp_example.py || error " 2D parallel example failed"
72- python ddp/main.py || error " ddp example failed"
73- }
74-
7538function fast_neural_style() {
7639 start
7740 if [ ! -d " saved_models" ]; then
@@ -223,9 +186,9 @@ function clean() {
223186}
224187
225188function run_all() {
226- # cpp
189+ # cpp moved to `run_cpp_examples.sh```
227190 dcgan
228- distributed
191+ # distributed moved to `run_distributed_examples.sh`
229192 fast_neural_style
230193 imagenet
231194 language_translation
261224if [ " " == " $ERRORS " ]; then
262225 echo " Completed successfully with status $? "
263226else
264- echo " Some examples failed:"
265- printf " $ERRORS "
227+ echo " Some python examples failed:"
228+ printf " $ERRORS \n "
266229 # Exit with error (0-255) in case of failure in one of the tests.
267230 exit 1
268231
0 commit comments