doc-exports/docs/modelarts/umn/docker-modelarts_0029.html
Lai, Weijian 4e4b2d5f6d ModelArts UMN 23.3.0 Version.
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
Co-authored-by: Lai, Weijian <laiweijian4@huawei.com>
Co-committed-by: Lai, Weijian <laiweijian4@huawei.com>
2024-06-26 07:03:02 +00:00

34 lines
5.6 KiB
HTML

<a name="EN-US_TOPIC_0000001948506073"></a><a name="EN-US_TOPIC_0000001948506073"></a>
<h1 class="topictitle1">Migrating an Image to ModelArts Training</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_p0356201419584">To migrate an image to the new training management version, perform the following operations:</p>
<ol id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_ol1048413498553"><li id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_li632551775716">Add the default user group <strong id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_b87995467921547">ma-group</strong> (<strong id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_b13944737621547">GID</strong> = <strong id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_b117189825321547">100</strong>) for the image of the new-version training management. If the user group whose <strong id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_b86551618111012">GID</strong> is <strong id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_b14951320141017">100</strong> exists, skip this step.</li><li id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_li448464915556">Add the default user <strong id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_b31619761121547">ma-user</strong> (<strong id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_b106770309421547">UID</strong> = <strong id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_b200918502721547">1000</strong>) for the image of the new-version training management. If the user whose <strong id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_b7181835161011">UID</strong> is <strong id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_b3199163815103">1000</strong> exists, skip this step.</li><li id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_li285653105710">Modify the permission on files in the image to allow <strong id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_b116980724921547">ma-user</strong> whose <strong id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_b713681551110">UID</strong> is <strong id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_b885612205117">1000</strong> to read and write the files.</li></ol>
<p id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_p1299711565019">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.</p>
<pre class="screen" id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_screen18742191112347">FROM {<em id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_i7484046181713">An existing image</em>}
USER root
RUN groupadd ma-group -g 100 &amp;&amp; \
useradd -d /home/ma-user -m -u 1000 -g 100 -s /bin/bash ma-user
# [important] avoid missing training log
ENV PYTHONUNBUFFERED=1
USER ma-user
WORKDIR /home/ma-user</pre>
<p id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_p218745113113">In the new-version training management, custom images are executed by the user whose <strong id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_b61721059188">UID</strong> is <strong id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_b94062718185">1000</strong> by default. Before using an image in the new-version training management, check image file permissions on the server where the image was built. The process is as follows:</p>
<p id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_p147134521553">Run the following command to specify the user whose <strong id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_b1571616309185">UID</strong> is <strong id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_b1970063312185">1000</strong> to run the image:</p>
<pre class="screen" id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_screen67390521812">docker run -u 1000 -ti {<em id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_i78229412421547">Custom image</em>} bash</pre>
<p id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_p386035514473">Run the boot command (such as the following command) in the container during image runtime:</p>
<pre class="screen" id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_screen1321718914814">python train.py</pre>
<p id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_p455115154218">Check whether there are any <strong id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_b132273161421547">Permission denied</strong> error.</p>
<p id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_p1488048387">If <strong id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_b106219748221547">Permission denied</strong> is displayed for a file, for example, <strong id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_b132892701621547">train.py</strong>, run the following command to change the file that belongs to the user whose <strong id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_b10931172384217">UID</strong> is <strong id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_b442142554216">1000</strong>:</p>
<pre class="screen" id="EN-US_TOPIC_0000001948506073__en-us_topic_0000001846137729_screen1617216415361">chown 1000 train.py</pre>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="docker-modelarts_0017.html">Using a Custom Image to Train Models (New-Version Training)</a></div>
</div>
</div>