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
On this page

Migrating Existing Images to ModelArts

Updated on 2024-12-26 GMT+08:00

Description

An image is available on the local host and needs to be adapted on the cloud for ModelArts model training.

Procedure

  1. Modify an existing image by referring to the following Dockerfile so that the image complies with specifications for custom images of the model training.
    FROM {An existing image}
    
    USER root
    
    # If the user group whose GID is 100 already exists, delete the groupadd command.
    RUN groupadd ma-group -g 100
    # If the user whose UID is 1000 already exists, delete the useradd command.
    RUN useradd -m -d /home/ma-user -s /bin/bash -g 100 -u 1000 ma-user
    
    # Modify the permissions on image files so that user ma-user whose UID is 1000 can read and write the files.
    RUN chown -R ma-user:100 {Path to the Python software package}
    
    # Configure the preset environment variables of the container image.
    # Set PYTHONUNBUFFERED to 1 to prevent log loss.
    ENV PYTHONUNBUFFERED=1
    
    # Configure the default user and working directory of the container image.
    USER ma-user
    WORKDIR /home/ma-user

    Note:

    1. Add the default user group ma-group (gid = 100) of the model training for the image.
      NOTE:

      If the user group whose gid is 100 already exists, the error message "groupadd: GID '100' already exists" may be displayed. You can use the cat /etc/group | grep 100 command to check whether the user group whose GID is 100 exists.

      If the user group whose gid is 100 already exists, skip this step and delete the command RUN groupadd ma-group -g 100 from the Dockerfile.

    2. Add the default user ma-user (uid = 1000) of the model training for the image.
      NOTE:

      If the user whose uid is 1000 already exists, the error message "useradd: UID 1000 is not unique" may be displayed. You can use the cat /etc/passwd | grep 1000 command to check whether the user whose UID is 1000 exists.

      If the user whose uid is 1000 already exists, skip this step and delete the command RUN useradd -d /home/ma-user -m -u 1000 -g 100 -s /bin/bash ma-user from the Dockerfile.

    3. Modify the permissions on files in the image to allow ma-user whose uid is 1000 to read and write the files.
  2. After editing the Dockerfile, run the following command to build an image:
    docker build -f Dockerfile . -t {New image}
  3. Upload the new image to SWR. For details, see 6.
  4. Create a training job on ModelArts.
    1. Log in to the ModelArts console.
    2. In the navigation pane on the left, choose Model Training > Training Jobs.
    3. Click Create Training Job. On the displayed page, configure the parameters by referring to Table 1. For details about the parameters, see Creating a Production Training Job.
      Table 1 Creating a training job using a custom image

      Parameter

      Description

      Algorithm Type

      Mandatory. Select Custom algorithm.

      Boot Mode

      Mandatory. Select Custom image.

      Image

      Mandatory. Select the image uploaded to SWR for container image.

      Code Directory

      OBS directory where the training code file is stored. Configure this parameter only if your custom image does not contain training code.

      • Upload code to the OBS bucket beforehand. The total size of files in the directory cannot exceed 5 GB, the number of files cannot exceed 1,000, and the folder depth cannot exceed 32.
      • The training code file is automatically downloaded to the ${MA_JOB_DIR}/demo-code directory of the training container when the training job is started. demo-code is the last-level OBS directory for storing the code. For example, if Code Directory is set to /test/code, the training code file is downloaded to the ${MA_JOB_DIR}/code directory of the training container.

      User ID

      User ID for running the container. The default value 1000 is recommended.

      If the UID needs to be specified, its value must be within the specified range. The UID ranges of different resource pools are as follows:

      • Public resource pool: 1000 to 65535
      • Dedicated resource pool: 0 to 65535

      Boot Command

      Mandatory. Command for booting an image.

      When a training job is running, the boot command is automatically executed after the code directory is downloaded.
      • If the training boot script is a .py file, train.py for example, the boot command is as follows:
        python ${MA_JOB_DIR}/demo-code/train.py
      • If the training boot script is an .sh file, main.sh for example, the boot command is as follows.
        bash ${MA_JOB_DIR}/demo-code/main.sh

      You can use semicolons (;) and ampersands (&&) to combine multiple commands. demo-code in the command is the last-level OBS directory where the code is stored. Replace it with the actual one.

      Local Code Directory

      Specify the local directory of a training container. When a training starts, the system automatically downloads the code directory to this directory.

      (Optional) The default local code directory is /home/ma-user/modelarts/user-job-dir.

      Work Directory

      During training, the system automatically runs the cd command to execute the boot file in this directory.

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