diff --git a/model_zoo/official/cv/resnet/resnet101_imagenet2012_config.yaml b/model_zoo/official/cv/resnet/resnet101_imagenet2012_config.yaml index 7c6971c860c..0ce8e0161d0 100644 --- a/model_zoo/official/cv/resnet/resnet101_imagenet2012_config.yaml +++ b/model_zoo/official/cv/resnet/resnet101_imagenet2012_config.yaml @@ -49,6 +49,10 @@ enable_cache: False cache_session_id: "" mode_name: "GRAPH" acc_mode: "O0" +all_reduce_fusion_config: + - 2 + - 60 + - 220 # Export options device_id: 0 diff --git a/model_zoo/official/cv/resnet/resnet50_cifar10_config.yaml b/model_zoo/official/cv/resnet/resnet50_cifar10_config.yaml index 428bfcd2b40..51021bb5a39 100644 --- a/model_zoo/official/cv/resnet/resnet50_cifar10_config.yaml +++ b/model_zoo/official/cv/resnet/resnet50_cifar10_config.yaml @@ -49,6 +49,9 @@ enable_cache: False cache_session_id: "" mode_name: "GRAPH" acc_mode: "O0" +all_reduce_fusion_config: + - 2 + - 115 # Export options device_id: 0 diff --git a/model_zoo/official/cv/resnet/resnet50_imagenet2012_Acc_config.yaml b/model_zoo/official/cv/resnet/resnet50_imagenet2012_Acc_config.yaml index 6b0a8832b65..62928b37564 100644 --- a/model_zoo/official/cv/resnet/resnet50_imagenet2012_Acc_config.yaml +++ b/model_zoo/official/cv/resnet/resnet50_imagenet2012_Acc_config.yaml @@ -51,6 +51,9 @@ enable_cache: False cache_session_id: "" mode_name: "GRAPH" acc_mode: "O1" +all_reduce_fusion_config: + - 85 + - 160 # Export options device_id: 0 diff --git a/model_zoo/official/cv/resnet/resnet50_imagenet2012_GPU_config.yaml b/model_zoo/official/cv/resnet/resnet50_imagenet2012_GPU_config.yaml index 0bbce0d7d80..dd4b492f7e3 100644 --- a/model_zoo/official/cv/resnet/resnet50_imagenet2012_GPU_config.yaml +++ b/model_zoo/official/cv/resnet/resnet50_imagenet2012_GPU_config.yaml @@ -52,6 +52,9 @@ enable_cache: False cache_session_id: "" mode_name: "GRAPH" acc_mode: "O0" +all_reduce_fusion_config: + - 85 + - 160 # Export options device_id: 0 diff --git a/model_zoo/official/cv/resnet/resnet50_imagenet2012_Thor_config.yaml b/model_zoo/official/cv/resnet/resnet50_imagenet2012_Thor_config.yaml index 29b8997e2b7..2b730eb81ff 100644 --- a/model_zoo/official/cv/resnet/resnet50_imagenet2012_Thor_config.yaml +++ b/model_zoo/official/cv/resnet/resnet50_imagenet2012_Thor_config.yaml @@ -52,6 +52,9 @@ enable_cache: False cache_session_id: "" mode_name: "GRAPH" acc_mode: "O0" +all_reduce_fusion_config: + - 85 + - 160 # Export options device_id: 0 diff --git a/model_zoo/official/cv/resnet/resnet50_imagenet2012_config.yaml b/model_zoo/official/cv/resnet/resnet50_imagenet2012_config.yaml index b86f26f05fd..a9873711004 100644 --- a/model_zoo/official/cv/resnet/resnet50_imagenet2012_config.yaml +++ b/model_zoo/official/cv/resnet/resnet50_imagenet2012_config.yaml @@ -51,6 +51,9 @@ enable_cache: False cache_session_id: "" mode_name: "GRAPH" acc_mode: "O0" +all_reduce_fusion_config: + - 85 + - 160 # Export options device_id: 0 diff --git a/model_zoo/official/cv/resnet/se-resnet50_imagenet2012_config.yaml b/model_zoo/official/cv/resnet/se-resnet50_imagenet2012_config.yaml index f313c1098e4..7d98865ddc9 100644 --- a/model_zoo/official/cv/resnet/se-resnet50_imagenet2012_config.yaml +++ b/model_zoo/official/cv/resnet/se-resnet50_imagenet2012_config.yaml @@ -52,6 +52,9 @@ enable_cache: False cache_session_id: "" mode_name: "GRAPH" acc_mode: "O0" +all_reduce_fusion_config: + - 1 + - 100 # Export options device_id: 0 diff --git a/model_zoo/official/cv/resnet/src/dataset.py b/model_zoo/official/cv/resnet/src/dataset.py index 34ab2869a6b..6981da3f1d7 100755 --- a/model_zoo/official/cv/resnet/src/dataset.py +++ b/model_zoo/official/cv/resnet/src/dataset.py @@ -355,6 +355,7 @@ def create_dataset4(dataset_path, do_train, repeat_num=1, batch_size=32, target= device_num = get_group_size() else: device_num = 1 + ds.config.set_prefetch_size(64) if device_num == 1: data_set = ds.ImageFolderDataset(dataset_path, num_parallel_workers=12, shuffle=True) else: diff --git a/model_zoo/official/cv/resnet/train.py b/model_zoo/official/cv/resnet/train.py index ecdc24325db..e1440dd65e0 100755 --- a/model_zoo/official/cv/resnet/train.py +++ b/model_zoo/official/cv/resnet/train.py @@ -106,9 +106,9 @@ def set_parameter(): set_algo_parameters(elementwise_op_strategy_follow=True) if config.net_name == "resnet50" or config.net_name == "se-resnet50": if config.acc_mode not in ["O1", "O2"]: - context.set_auto_parallel_context(all_reduce_fusion_config=[85, 160]) + context.set_auto_parallel_context(all_reduce_fusion_config=config.all_reduce_fusion_config) elif config.net_name == "resnet101": - context.set_auto_parallel_context(all_reduce_fusion_config=[80, 210, 313]) + context.set_auto_parallel_context(all_reduce_fusion_config=config.all_reduce_fusion_config) init() # GPU target else: @@ -117,7 +117,7 @@ def set_parameter(): parallel_mode=ParallelMode.DATA_PARALLEL, gradients_mean=True) if config.net_name == "resnet50": - context.set_auto_parallel_context(all_reduce_fusion_config=[85, 160]) + context.set_auto_parallel_context(all_reduce_fusion_config=config.all_reduce_fusion_config) def init_weight(net): """init_weight"""