Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Horovod/MPI/MindSpore-GPU

Updated on 2024-06-21 GMT+08:00

ModelArts provides multiple AI frameworks for different engines. When you use these engines for model training, the algorithm codes during training need to be adapted accordingly. This section introduces how to make adaptions to the Horovod/MPI/MindSpore-GPU engine.

Horovod/MPI/MindSpore-GPU Startup Principle

Specifications and number of nodes

In this case, GPU: 8 × GP-Vnt1 | CPU: 72 cores | Memory: 512 GB is used as an example to describe how to allocate ModelArts resources for single-node and distributed jobs.

For a single-node job (running on only one node), ModelArts starts a training container that exclusively uses the resources on the node.

For a distributed job (running on more than one node), there are as many workers as the nodes that are selected during job creation. Each worker is allocated with the compute resources of the selected specification. For example, if there are 2 compute nodes, two workers will be started, and each worker owns the compute resources of GPU: 8 × GP-Vnt1 | CPU: 72 cores | Memory: 512 GB.

Network communication

  • For a single-node job, no network communication is required.
  • For a distributed job, network communications are required in nodes and between nodes.

In nodes

NVLink and shared memory are used for communication.

Between nodes

If there is more than one compute node, PyTorch distributed training will be started. The following figure shows the network communications between workers in PyTorch distributed training. Workers can communicate with each other using the container network and a 100-Gbit/s InfiniBand or RoCE NIC. RoCE NICs are described specifically for certain specifications. The containers can communicate through DNS domain names, which is suitable for small-scale point-to-point communication that requires average network performance. The InfiniBand and RoCE NICs are suitable for distributed training jobs using collective communication that require high-performance network.

Figure 1 Network communications for distributed training

Boot Commands

By default, the training service uses the python interpreter in the job image to start up the training script. To obtain the python interpreter, run the which python command. The working directory during startup is /home/ma-user/user-job-dir/<The code directory name>, which is the directory returned by running pwd or os.getcwd() in python.

Boot commands

mpirun \        
-np ${OPENMPI_NP} \       
-hostfile ${OPENMPI_HOST_FILE_PATH} \        
-mca plm_rsh_args "-p ${SSHD_PORT}" \        
-tune ${TUNE_ENV_FILE} \        
${OPENMPI_BIND_ARGS} \        
${OPENMPI_X_ARGS} \        
${OPENMPI_MCA_ARGS} \        
${OPENMPI_EXTRA_ARGS} \        
python <Relative path of the startup file> <Job parameters>
  • OPENMPI_NP: number of processes started by mpirun. The default value is the number of GPUs multiplied by the number of nodes. Do not modify this value.
  • OPENMPI_HOST_FILE_PATH: value of hostfile. Do not modify this value.
  • SSHD_PORT: Port for SSH login. Do not modify this value.
  • TUNE_ENV_FILE: environment variables of worker-0. Broadcast the following environment variables to other worker nodes of the current training job.
    • env with the MA_ prefix
    • env with the SHARED_ prefix
    • env with the S3_ prefix
    • env of PATH
    • env with the VC_WORKER_ prefix
    • env with the SCC prefix
    • env with the CRED prefix
      env|grep -E '^MA_|^SHARED_|^S3_|^PATH|^VC_WORKER_|^SCC|^CRED'|grep -v '=$'> ${TUNE_ENV_FILE}
  • OPENMPI_BIND_ARGS: process pinning with the mpirun cpu command. The default setting is as follows:
    OPENMPI_BIND_ARGS="-bind-to none -map-by slot"
  • OPENMPI_X_ARGS: -x parameters of the mpirun command. The default settings are as follows:
    OPENMPI_X_ARGS="-x LD_LIBRARY_PATH -x HOROVOD_MPI_THREADS_DISABLE=1 -x NCCL_DEBUG=INFO -x NCCL_SOCKET_IFNAME=ib0,bond0,eth0 -x NCCL_SOCKET_FAMILY=AF_INET -x NCCL_IB_DISABLE=0"
  • OPENMPI_X_ARGS: -mca parameters of the mpirun command. The default setting is as follows:
    OPENMPI_MCA_ARGS="-mca pml ob1 -mca btl ^openib -mca plm_rsh_no_tree_spawn true"
  • OPENMPI_EXTRA_ARGS: parameters passed to mpirun. The default value is empty.
  • Relative path of the startup file: path of the startup file relative to /home/ma-user/user-job-dir/<The code directory name>
  • Job parameters: running parameters configured for a training job
Figure 2 Creating a training job

Configure the parameters by referring to the above figure. Then, run the following command on the console background:

mpirun \        
-np ${np} \        
-hostfile ${OPENMPI_HOST_FILE_PATH} \        
-mca plm_rsh_args "-p ${SSHD_PORT}" \        
-tune ${TUNE_ENV_FILE} \        
${OPENMPI_BIND_ARGS} \        
${OPENMPI_X_ARGS} \        
${OPENMPI_MCA_ARGS} \        
${OPENMPI_EXTRA_ARGS} \        
python /home/ma-user/user-job-dir/gpu-train/train.py --datasets=obs://modelarts-train-test/gpu-train/data_url_0
NOTE:

If you are using a Horovod, MPI, or MindSpore-GPU engine for model training, the boot commands for single-node jobs and distributed jobs are the same.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback