Help Center/ ModelArts/ Image Management/ FAQs/ How Do I Reduce the Size of an Image Created Locally or on ECS?
Updated on 2024-06-21 GMT+08:00

How Do I Reduce the Size of an Image Created Locally or on 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 Huawei Cloud, avoid selecting an image with unrelated components (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 in the same layer.

    Recommended:

    RUN pip install six &&\
        pip install numpy

    Not recommended:

    RUN pip install six
    RUN pip install numpy

    The more the image layers are, the larger the image is.

  • Install and uninstall the packages in the same layer.

    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