diff --git a/cv/classification/acmix/pytorch/README.md b/cv/classification/acmix/pytorch/README.md index b7f5e724480dc2817883180c8c401faed58e963c..c46c7e6aaed400225cb647de14fc60a0da323182 100644 --- a/cv/classification/acmix/pytorch/README.md +++ b/cv/classification/acmix/pytorch/README.md @@ -15,7 +15,10 @@ Sign up and login in [imagenet official website](https://www.image-net.org/index ### Swin-S + ACmix on ImageNet using 8 cards: ``` -bash run.sh 8 acmix_swin_small_patch4_window7_224.yaml +mkdir -p /data/datasets +ln -s /path/to/imagenet /data/datasets/imagenet +source /scripts/_utils/common_env_setup.sh +bash run.sh ``` ## Results on BI-V100 @@ -26,4 +29,4 @@ bash run.sh 8 acmix_swin_small_patch4_window7_224.yaml ## Reference -https://github.com/leaplabthu/acmix \ No newline at end of file +https://github.com/leaplabthu/acmix diff --git a/cv/classification/acmix/pytorch/run.sh b/cv/classification/acmix/pytorch/run.sh index 8041c1e23296f1f59d94f249c13598707f230967..96ed6bee228407e586b3802ff2a297b98570759e 100644 --- a/cv/classification/acmix/pytorch/run.sh +++ b/cv/classification/acmix/pytorch/run.sh @@ -1,9 +1,14 @@ -NGPU=$1 -CONFIG=$2 -DATA_PATH=$3 +#!/bin/bash -cd Swin-Transformer +source ${ROOT_DIR}/scripts/_utils/common_env_setup.sh -python3 -m torch.distributed.launch --nproc_per_node ${NGPU} \ - --master_port 12345 main.py --cfg configs/${CONFIG} \ - --data-path ${DATA_PATH} --batch-size 128 +DATA_PATH=${DATA_DIR}/imagenet +CONFIG="acmix_swin_small_patch4_window7_224.yaml" + +cd ${ROOT_DIR}/cv/classification/acmix/pytorch/Swin-Transformer + +python3 -m torch.distributed.launch --master_port 12345 --nproc_per_node ${NGPU} \ + main.py --cfg configs/${CONFIG} \ + --data-path ${DATA_PATH} \ + --batch-size 128 \ + "$@" diff --git a/scripts/_utils/common_env_setup.sh b/scripts/_utils/common_env_setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..8ecce5473500a900a263e5b42c5221224ae50aac --- /dev/null +++ b/scripts/_utils/common_env_setup.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +ROOT_DIR=$(git rev-parse --show-toplevel) +export ROOT_DIR=$ROOT_DIR + +data_dir=$DATA_DIR +if [ -n "$data_dir" ]; then + data_dir=$DATA_DIR +else + data_dir=$ROOT_DIR/data/datasets +fi +DATA_DIR=$data_dir +export DATA_DIR=$data_dir + +devices=$CUDA_VISIBLE_DEVICES +if [ -n "$devices" ]; then + _devices=(${devices//,/ }) + num_devices=${#_devices[@]} +else + num_devices=1 + export CUDA_VISIBLE_DEVICES=0 + echo "CUDA_VISIBLE_DEVICES Not found, set nproc_per_node = ${num_devices}" +fi +NGPU=${num_devices} +export NGPU=$NGPU diff --git a/scripts/acmix/pytorch/run.sh b/scripts/acmix/pytorch/run.sh new file mode 120000 index 0000000000000000000000000000000000000000..d48eb835977e86a91603c22e4d3bd4f338123249 --- /dev/null +++ b/scripts/acmix/pytorch/run.sh @@ -0,0 +1 @@ +../../../cv/classification/acmix/pytorch/run.sh \ No newline at end of file