Help Center/ ModelArts/ FAQs/ Service Deployment/ Model Management/ Importing Models/ How Do I Edit the Installation Package Dependency Parameters in a Model Configuration File When Importing a Model?
Updated on 2024-06-11 GMT+08:00

How Do I Edit the Installation Package Dependency Parameters in a Model Configuration File When Importing a Model?

Symptom

When importing a model from OBS or a container image, edit a model configuration file. The model configuration file describes the model usage, computing framework, precision, inference code dependency package, and model API. The configuration file must be in JSON format. dependencies in the model configuration file specifies the dependencies required for configuring the model inference code. This parameter requires the package name, installation method, and version constraints. For details, see The following section describes how to edit dependencies in the model configuration file during model import.

Solution

The installation packages must be installed in sequence. For example, before installing mmcv-full, install Cython, pytest-runner, and pytest. In the configuration file, Cython, pytest-runner, and pytest are ahead of mmcv-full.

Example:

"dependencies": [
    {
    "installer": "pip",
    "packages": [
        {
            "package_name": "Cython"
        },
        {
            "package_name": "pytest-runner"
        },
        {
            "package_name": "pytest"
        },
        {
            "restraint": "ATLEAST",
            "package_version": "5.0.0",
            "package_name": "Pillow"
        },
        {
            "restraint": "ATLEAST",
            "package_version": "1.4.0",
            "package_name": "torch"
        },
        {
            "restraint": "ATLEAST",
            "package_version": "1.19.1",
            "package_name": "numpy"
        },
        {
            "package_name": "mmcv-full"
        }
      ]
   }
]

If installing mmcv-full failed, the possible cause is that GCC was not installed in the base image, leading to a compilation failure. In this case, use the wheel package on premises to install mmcv-full.

Example:

"dependencies": [
    {
    "installer": "pip",
    "packages": [
        {
            "package_name": "Cython"
        },
        {
            "package_name": "pytest-runner"
        },
        {
            "package_name": "pytest"
        }, 
        {
            "restraint": "ATLEAST",
            "package_version": "5.0.0",
            "package_name": "Pillow"
        },
        {
            "restraint": "ATLEAST",
            "package_version": "1.4.0",
            "package_name": "torch"
        },
        {
            "restraint": "ATLEAST",
            "package_version": "1.19.1",
            "package_name": "numpy"
        },
        {
            "package_name": "mmcv_full-1.3.9-cp37-cp37m-manylinux1_x86_64.whl"
        }
      ]
    }
]

dependencies in the model configuration file supports multiple dependency structure arrays in list format.

Example:
"dependencies": [
    {
    "installer": "pip",
    "packages": [
        {
            "package_name": "Cython"
        },
        {
            "package_name": "pytest-runner"
        },
        {
            "package_name": "pytest"
        }, 
        {
            "package_name": "mmcv_full-1.3.9-cp37-cp37m-manylinux1_x86_64.whl"
        }
      ]
    },
    {
    "installer": "pip",
    "packages": [
        {
            "restraint": "ATLEAST",
            "package_version": "5.0.0",
            "package_name": "Pillow"
        },
        {
            "restraint": "ATLEAST",
            "package_version": "1.4.0",
            "package_name": "torch"
        },
        {
            "restraint": "ATLEAST",
            "package_version": "1.19.1",
            "package_name": "numpy"
        },
      ]
    }
]