Help Center/ ModelArts/ Troubleshooting/ Training Jobs/ In-Cloud Migration Adaptation Issues/ ModelArts Training Job Failed to Parse Parameters and an Error Is Displayed in the Log
Updated on 2024-04-11 GMT+08:00

ModelArts Training Job Failed to Parse Parameters and an Error Is Displayed in the Log

Symptom

The ModelArts training job failed to parse parameters, and the following error occurs:

error: unrecognized arguments: --data_url=xxx://xxx/xxx
error: unrecognized arguments: --init_method=tcp://job
absl.flags._exceptions.UnrecognizedFlagError:Unknown command line flag 'task_index'

Possible Cause

  • The parameters are not defined.
  • In the training environment, the system may input parameters that are not defined in the Python script. As a result, the parameters cannot be parsed, and an error is displayed in the log.

Solution

  1. Define the parameters. The following is a code sample for reference:
    parser.add_argument('--init_method', default='tcp://xxx',help="init-method")
  2. Replace args = parser.parse_args() with args, unparsed = parser.parse_known_args(). The following is a code sample:
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('--data_url', type=str, default=None, help='obs path of dataset')
    args, unparsed = parser.parse_known_args()