Migrating an Image to ModelArts Training
- Add the default user group ma-group (GID = 100) of the new-version training management for the image.
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 command cat /etc/group | grep 100 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.
- Add the default user ma-user (UID = 1000) of the new-version training management for the image.
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 command cat /etc/passwd | grep 1000 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.
- Modify the permissions on files in the image to allow ma-user whose UID is 1000 to read and write the files.
You can modify an image by referring to the following Dockerfile so that the image complies with specifications for custom images of the new-version training management.
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
After editing the Dockerfile, run the following command to build a new image:
docker build -f Dockerfile . -t {New image}
Upload the new image to SWR. For details, see How Can I Log In to SWR and Upload Images to It?
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.