()
| 30 | |
| 31 | |
| 32 | def parse_option(): |
| 33 | parser = argparse.ArgumentParser( |
| 34 | 'InternVL training and evaluation script', add_help=False) |
| 35 | parser.add_argument('--cfg', type=str, required=True, metavar='FILE', help='path to config file') |
| 36 | parser.add_argument('--opts', help="Modify config options by adding 'KEY VALUE' pairs. ", default=None, nargs='+') |
| 37 | |
| 38 | # easy config modification |
| 39 | parser.add_argument('--batch-size', type=int, help='batch size for single GPU') |
| 40 | parser.add_argument('--dataset', type=str, help='dataset name', default=None) |
| 41 | parser.add_argument('--data-path', type=str, help='path to dataset') |
| 42 | parser.add_argument('--zip', action='store_true', help='use zipped dataset instead of folder dataset') |
| 43 | parser.add_argument('--cache-mode', type=str, default='part', choices=['no', 'full', 'part'], |
| 44 | help='no: no cache, ' |
| 45 | 'full: cache all data, ' |
| 46 | 'part: sharding the dataset into nonoverlapping pieces and only cache one piece' |
| 47 | ) |
| 48 | parser.add_argument('--pretrained', |
| 49 | help='pretrained weight from checkpoint, could be imagenet22k pretrained weight') |
| 50 | parser.add_argument('--resume', help='resume from checkpoint') |
| 51 | parser.add_argument('--output', default='work_dirs', type=str, metavar='PATH', |
| 52 | help='root of output folder, the full path is <output>/<model_name>/<tag> (default: output)' |
| 53 | ) |
| 54 | |
| 55 | parser.add_argument('--eval', action='store_true', help='Perform evaluation only') |
| 56 | parser.add_argument('--throughput', action='store_true', help='Test throughput only') |
| 57 | parser.add_argument('--save-ckpt-num', default=1, type=int) |
| 58 | parser.add_argument('--accumulation-steps', type=int, default=1, help='gradient accumulation steps') |
| 59 | |
| 60 | # distributed training |
| 61 | parser.add_argument('--local-rank', type=int, required=True, help='local rank for DistributedDataParallel') |
| 62 | |
| 63 | # deepspeed config |
| 64 | parser.add_argument('--disable-grad-scalar', action='store_true', help='disable Grad Scalar') |
| 65 | parser.add_argument('--offload-optimizer', type=str, default='none', choices=['cpu', 'none'], |
| 66 | help='enable optimizer offloading') |
| 67 | parser.add_argument('--offload-param', type=str, default='none', choices=['cpu', 'none'], |
| 68 | help='enable model offloading') |
| 69 | # To use Zero3, Please use main_accelerate.py instead. |
| 70 | # For this script, we are facing a similar issue as https://github.com/microsoft/DeepSpeed/issues/3068 |
| 71 | parser.add_argument('--zero-stage', type=int, default=1, choices=[1, 2], help='deep speed zero stage') |
| 72 | |
| 73 | args, unparsed = parser.parse_known_args() |
| 74 | config = get_config(args) |
| 75 | |
| 76 | return args, config |
| 77 | |
| 78 | |
| 79 | def seed_everything(seed, rank): |
no test coverage detected