# msrun Launching [![View Source On Gitee](https://mindspore-website.obs.cn-north-4.myhuaweicloud.com/website-images/master/resource/_static/logo_source_en.svg)](https://gitee.com/mindspore/docs/blob/master/tutorials/experts/source_en/parallel/msrun_launcher.md) ## Overview `msrun` is an encapsulation of the [Dynamic Cluster](https://www.mindspore.cn/tutorials/experts/en/master/parallel/dynamic_cluster.html) startup method. Users can use `msrun` to pull multi-process distributed tasks across nodes with a single command line instruction. Users can use `msrun` to pull up multi-process distributed tasks on each node with a single command line command, and there is no need to manually set [dynamic networking environment variables](https://www.mindspore.cn/tutorials/experts/en/master/parallel/dynamic_cluster.html). `msrun` supports both `Ascend`, `GPU` and `CPU` backends. As with the `Dynamic Cluster` startup, `msrun` has no dependencies on third-party libraries and configuration files. > - `msrun` is available after the user installs MindSpore, and the command `msrun --help` can be used to view the supported parameters. > - `msrun` supports `graph mode` as well as `PyNative mode`. A parameters list of command line:
Parameters | Functions | Types | Values | Instructions |
---|---|---|---|---|
--worker_num | The total number of Worker processes participating in the distributed task. | Integer | An integer greater than 0. The default value is 8. | The total number of Workers started on each node should be equal to this parameter: if the total number is greater than this parameter, the extra Worker processes will fail to register; if the total number is less than this parameter, the cluster will wait for a certain period of timeout before prompting the task to pull up the failed task and exit, and the size of the timeout window can be configured by the parameter cluster_time_out . |
--local_worker_num | The number of Worker processes pulled up on the current node. | Integer | An integer greater than 0. The default value is 8. | When this parameter is consistent with worker_num , it means that all Worker processes are executed locally. The node_rank value is ignored in this scenario. |
--master_addr | Specifies the IP address of the Scheduler. | String | Legal IP address. The default is 127.0.0.1. | msrun will automatically detect on which node to pull up the Scheduler process, and users do not need to care. If the corresponding address cannot be found, the training task will pull up and fail. IPv6 addresses are not supported in the current version The current version of msrun uses the ip -j addr command to query the current node address, which requires the user's environment to support this command. |
--master_port | Specifies the Scheduler binding port number. | Integer | Port number in the range 1024 to 65535. The default is 8118. | |
--node_rank | The index of the current node. | Integer | An integer greater than 0. The default value is -1. | This parameter is ignored in single-machine multi-card scenario. In multi-machine and multi-card scenarios, if this parameter is not set, the rank_id of the Worker process will be assigned automatically; if it is set, the rank_id will be assigned to the Worker process on each node according to the index. If the number of Worker processes per node is different, it is recommended that this parameter not be configured to automatically assign the rank_id. |
--log_dir | Worker, and Scheduler log output paths. | String | Folder path. Defaults to the current directory. | If the path does not exist, msrun creates the folder recursively. The log format is as follows: for the Scheduler process, the log is named scheduler.log ; For Worker process, log name is worker_[rank].log , where rank suffix is the same as the rank_id assigned to the Worker, but they may be inconsistent in multiple-machine and multiple-card scenarios where node_rank is not set. It is recommended that grep -rn "Global rank id" is executed to view rank_id of each Worker. |
--join | Whether msrun waits for the Worker as well as the Scheduler to exit. | Bool | True or False. Default: False. | If set to False, msrun will exit immediately after pulling up the process and check the logs to confirm that the distributed task is executing properly. If set to True, msrun waits for all processes to exit, collects the exception log and exits. |
--cluster_time_out | Cluster networking timeout in seconds. | Integer | Integer. Default: 600 seconds. | This parameter represents the waiting time in cluster networking. If no worker_num number of Workers register successfully beyond this time window, the task pull-up fails. |
task_script | User Python scripts. | String | Legal script path. | Normally, this parameter is the python script path, and msrun will pull up the process as python task_script task_script_args by default.msrun also supports this parameter as pytest. In this scenario the task script and task parameters are passed in the parameter task_script_args . |
task_script_args | Parameters for the user Python script. | Parameter list. | For example, msrun --worker_num=8 --local_worker_num=8 train.py --device_target=Ascend --dataset_path=/path/to/dataset |
Environment Variables | Functions | Values |
---|---|---|
MS_ROLE | This process role. |
The current version of msrun exports the following two values:
|
MS_SCHED_HOST | The IP address of the user-specified Scheduler. | Same as parameter --master_addr . |
MS_SCHED_PORT | User-specified Scheduler binding port number. | Same as parameter --master_port . |
MS_WORKER_NUM | The total number of Worker processes specified by the user. | Same as parameter --worker_num . |
MS_TOPO_TIMEOUT | Cluster Timeout Time. | Same as parameter --cluster_time_out . |
RANK_SIZE | The total number of Worker processes specified by the user. | Same as parameter --worker_num . |
RANK_ID | The rank_id assigned to the Worker process. | In a multi-machine multi-card scenario, if the parameter --node_rank is not set, RANK_ID will only be exported after the cluster is initialized.So to use this environment variable, it is recommended to set the --node_rank parameter correctly. |