From da0bf8de059d08dd04e296ed797501ddd6320ede Mon Sep 17 00:00:00 2001 From: ZeyangGao Date: Tue, 14 Sep 2021 16:45:53 +0800 Subject: [PATCH] fix bug of resnet --- model_zoo/research/cv/Pix2Pix/README.md | 12 ++++++------ .../Pix2Pix/scripts/run_distribute_train_ascend.sh | 4 ++-- .../cv/Pix2Pix/scripts/run_distribute_train_gpu.sh | 2 +- model_zoo/research/cv/Pix2Pix/src/utils/config.py | 4 ---- model_zoo/research/cv/Pix2Pix/train.py | 6 +++++- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/model_zoo/research/cv/Pix2Pix/README.md b/model_zoo/research/cv/Pix2Pix/README.md index 1dd77c79ba2..d410a9232f6 100644 --- a/model_zoo/research/cv/Pix2Pix/README.md +++ b/model_zoo/research/cv/Pix2Pix/README.md @@ -231,8 +231,8 @@ bash run_infer_310.sh [The path of the MINDIR for 310 infer] [The path of the da | Optimizer | Adam | Adam | | Loss Function | SigmoidCrossEntropyWithLogits Loss & L1 Loss | SigmoidCrossEntropyWithLogits Loss & L1 Loss | | outputs | probability | probability | -| Speed | 1pc(Ascend): 10 ms/step | 1pc(GPU): 50 ms/step | -| Total time | 1pc(Ascend): 0.3h | 1pc(GPU): 0.9 h | +| Speed | 1pc(Ascend): 10 ms/step | 1pc(GPU): 40 ms/step | +| Total time | 1pc(Ascend): 0.3h | 1pc(GPU): 0.8 h | | Checkpoint for Fine tuning | 207M (.ckpt file) | 207M (.ckpt file) | | Parameters | single Ascend | single GPU | @@ -245,8 +245,8 @@ bash run_infer_310.sh [The path of the MINDIR for 310 infer] [The path of the da | Optimizer | Adam | Adam | | Loss Function | SigmoidCrossEntropyWithLogits Loss & L1 Loss | SigmoidCrossEntropyWithLogits Loss & L1 Loss | | outputs | probability | probability | -| Speed | 1pc(Ascend): 20 ms/step | 1pc(GPU): 60 ms/step | -| Total time | 1pc(Ascend): 1.58h | 1pc(GPU): 2.2h | +| Speed | 1pc(Ascend): 20 ms/step | 1pc(GPU): 90 ms/step | +| Total time | 1pc(Ascend): 1.58h | 1pc(GPU): 3.3h | | Checkpoint for Fine tuning | 207M (.ckpt file) | 207M (.ckpt file) | ### Distributed Training Performance @@ -275,8 +275,8 @@ bash run_infer_310.sh [The path of the MINDIR for 310 infer] [The path of the da | Optimizer | Adam | Adam | | Loss Function | SigmoidCross55EntropyWithLogits Loss & L1 Loss | SigmoidCrossEntropyWithLogits Loss & L1 Loss | | outputs | probability | probability | -| Speed | 8pc(Ascend): 20 ms/step | 8pc(GPU): 30 ms/step | -| Total time | 8pc(Ascend): 1.2h | 8pc(GPU): 2.1h | +| Speed | 8pc(Ascend): 20 ms/step | 8pc(GPU): 40 ms/step | +| Total time | 8pc(Ascend): 1.2h | 8pc(GPU): 2.8h | | Checkpoint for Fine tuning | 207M (.ckpt file) | 207M (.ckpt file) | ### Evaluation Performance diff --git a/model_zoo/research/cv/Pix2Pix/scripts/run_distribute_train_ascend.sh b/model_zoo/research/cv/Pix2Pix/scripts/run_distribute_train_ascend.sh index a8782a17f50..7c4dd9b3622 100644 --- a/model_zoo/research/cv/Pix2Pix/scripts/run_distribute_train_ascend.sh +++ b/model_zoo/research/cv/Pix2Pix/scripts/run_distribute_train_ascend.sh @@ -29,8 +29,8 @@ get_real_path(){ fi } -export RANK_SIZE=$(get_real_path $1) -export DISTRIBUTE=$(get_real_path $2) +export RANK_SIZE=$1 +export DISTRIBUTE=$2 export RANK_TABLE_FILE=$(get_real_path $3) export DATASET_PATH=$(get_real_path $4) diff --git a/model_zoo/research/cv/Pix2Pix/scripts/run_distribute_train_gpu.sh b/model_zoo/research/cv/Pix2Pix/scripts/run_distribute_train_gpu.sh index 761a8d10f45..e016c7deb48 100644 --- a/model_zoo/research/cv/Pix2Pix/scripts/run_distribute_train_gpu.sh +++ b/model_zoo/research/cv/Pix2Pix/scripts/run_distribute_train_gpu.sh @@ -58,7 +58,7 @@ then --run_distribute 1 --device_num $3 --dataset_size 400 --train_data_dir $PATH1 --pad_mode REFLECT &> log & elif [ $2 == 'maps' ]; then - mpirun --allow-run-as-root -n 1 --output-filename log_output --merge-stderr-to-stdout \ + mpirun --allow-run-as-root -n $3 --output-filename log_output --merge-stderr-to-stdout \ python train.py --device_target GPU --device_num $3 --dataset_size 1096 \ --run_distribute 1 --train_data_dir $PATH1 --pad_mode REFLECT &> log & fi diff --git a/model_zoo/research/cv/Pix2Pix/src/utils/config.py b/model_zoo/research/cv/Pix2Pix/src/utils/config.py index 9040fa14a33..d407e07335c 100644 --- a/model_zoo/research/cv/Pix2Pix/src/utils/config.py +++ b/model_zoo/research/cv/Pix2Pix/src/utils/config.py @@ -19,7 +19,6 @@ import argparse import ast -from mindspore import context def get_args(): @@ -71,7 +70,4 @@ def get_args(): parser.add_argument('--predict_dir', type=str, default='./results/predict/', help='during validating, the file path of Generated image.') args = parser.parse_args() - - context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id) - return args diff --git a/model_zoo/research/cv/Pix2Pix/train.py b/model_zoo/research/cv/Pix2Pix/train.py index 83148d7ea4a..30bf8a74a09 100644 --- a/model_zoo/research/cv/Pix2Pix/train.py +++ b/model_zoo/research/cv/Pix2Pix/train.py @@ -43,7 +43,7 @@ if __name__ == '__main__': print("ds.shape:", ds.output_shapes()) steps_per_epoch = ds.get_dataset_size() - + context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target) if args.device_target == 'Ascend': if args.run_distribute: print("Ascend distribute") @@ -55,6 +55,8 @@ if __name__ == '__main__': init() rank = get_rank() + else: + context.set_context(device_id=args.device_id) elif args.device_target == 'GPU': if args.run_distribute: print("GPU distribute") @@ -63,6 +65,8 @@ if __name__ == '__main__': context.set_auto_parallel_context(device_num=get_group_size(), parallel_mode=ParallelMode.DATA_PARALLEL, gradients_mean=True) + else: + context.set_context(device_id=args.device_id) netG = get_generator() netD = get_discriminator()