Training Tool

The train.py tool provided by the algorithm package serves as the core entry point for model training. It supports single-GPU/multi-GPU and single-node/multi-node training modes, while being compatible with the configuration and execution of different training phases (e.g., floating-point training, quantization calibration, quantization-aware training). Flexible control over the entire training pipeline can be achieved via concise command-line arguments.

Usage

The basic command format for initiating model training is as follows. It supports specification of core training configurations via command-line arguments, as well as refined definition of the training pipeline in conjunction with a config file.

python tools/train.py   --stage  \
                        --config  \
                        --device-ids \
                        --dist-url  \
                        --launcher  \
                        --pipeline-test \
                        --opts  \
                        --opts-overwrite \
                        --level

Parameters Introduction

ParameterDescription
--stageDifferent training and inference stages. Valid choices: float, calibration, qat, int_infer.
--config, -cPath to the config file.
--device-ids, -idsList of GPUs to use.
--dist-urlServer address for multi-machine training, default is auto.
--launcherThe startup method for multi-machine operation, please select "torch".
--pipeline-testWhether to run pipeline test.
--optsModify config parameters via command line.
--opts-overwriteWhether to overwrite config parameters.
--levelLogging level for non-rank0 processes.

Usgae Example

Taking resnet50_imagenet as an example, to launch multi-GPU quantization-aware training:

python3 tools/predict.py --stage qat \
                      --config configs/classification/resnet50_imagenet.py \
                      --device-ids 0,1

For a detailed introduction to the configuration file, please refer to the [Configuration] section [config configuration] (../config/keywords).