Help Center/ ModelArts/ FAQs/ ModelArts Standard Images/ How Do I Reduce the Size of the Target Image Created on the Local PC or ECS?
Updated on 2025-08-28 GMT+08:00

How Do I Reduce the Size of the Target Image Created on the Local PC or ECS?

Choose a smaller image that fits your needs. For instance, if you are creating a PyTorch 2.1+CUDA 12.2 image and cannot find an exact match from the official website, preferentially select an image that does not have either the PyTorch environment or CUDA installed instead of selecting an image with neither installed (like MindSpore+CUDA 11.X). Otherwise, both the base and target images will end up large.

You can take the following measures to reduce the size of an image:

  • Reduce layers of the target image.

    If two pip packages six and numpy need to be installed, install them at the same layer.

    Recommended:

    RUN pip install six &&\
        pip install numpy

    Not recommended:

    RUN pip install six
    RUN pip install numpy

    An image with more layers takes up more space.

  • Install and uninstall the packages at the same layer.

    For example, to uninstall an SCC package downloaded from the official website, do as follows:

    Recommended:

    RUN mkdir -p /tmp/scc && \
        cd /tmp/scc && \
        wget http://100.95.151.167:6868/aarch64/euler/dls-release/euleros-arm/compiled-software/seccomponent-1.1.0-release.aarch64.rpm && \
        rpm -ivh /tmp/scc/seccomponent-1.1.0-release.aarch64.rpm --force --nodeps && \
        rm -rf /tmp/scc

    Not recommended:

    RUN mkdir -p /tmp/scc && \
        cd /tmp/scc && \
        wget http://100.95.151.167:6868/aarch64/euler/dls-release/euleros-arm/compiled-software/seccomponent-1.1.0-release.aarch64.rpm && \
        rpm -ivh /tmp/scc/seccomponent-1.1.0-release.aarch64.rpm --force --nodeps
    RUN rm -rf /tmp/scc