Files
doc-exports/docs/modelarts/umn/modelarts_13_0012.html
Lai, Weijian 6aa966a79a ModelArts UMN 24.3.0 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Lai, Weijian <laiweijian4@huawei.com>
Co-committed-by: Lai, Weijian <laiweijian4@huawei.com>
2024-11-02 09:04:52 +00:00

2.1 KiB

Failed to Parse Parameters and Log Error Occurs

Symptom

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

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

Possible Cause

In the training environment, the system may transfer other parameter names that are not defined in the Python script. As a result, the parameters failed to be parsed, and an error occurs in the log.

Solution

Replace args = parser.parse_args() with the args, unparsed = parser.parse_known_args() parsing method. The following is a code example.

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()