After you obtain a trained model, you can use a CLI to deploy the model as an online service in the Elastic Algorithm Service (EAS) module of Platform for AI (PAI). This topic describes how to use EASCMD to deploy a model service.
Use EASCMD
The EASCMD client allows you to create, view, update, and delete model services on your server. You can specify multiple instance types when you create a service. For more information, see Specify multiple instance types. The following steps show how to use the Linux64 version of the EASCMD client to deploy a service.
Step 1: Download the client and complete authentication
If you are using an Alibaba Cloud image in a Data Science Workshop (DSW) environment, the EASCMD client is preinstalled in /etc/dsw/eascmd64
. Otherwise, you must first Download the EASCMD client and complete identity authentication.
Step 2: Prepare JSON file
For information about how to configure the service deployment parameters, see Parameters of model services.
Sample file of service.json
:
{
"cloud": {
"computing": {
"instances": [
{
"type": "ecs.c7a.large"
}
]
}
},
"containers": [
{
"image": "****-registry.cn-beijing.cr.aliyuncs.com/***/***:latest",
"port": 8000,
"script": "python app.py"
}
],
"metadata": {
"cpu": 2,
"instance": 1,
"memory": 4000,
"name": "demo"
}
}
If you are using the DSW environment, you must upload the JSON file. For more information, see Upload or download data files.
Step 3: Deploy a service
Run the following command in the directory that contains the JSON file to deploy the service. This topic takes Linux as an example. For more information, see Run commands to use the EASCMD client.
eascmdwin64 create <service.json>
Replace <service.json> with the name of your actual JSON file.
Sample return:
[RequestId]: 1651567F-8F8D-4A2B-933D-F8D3E2DD****
+-------------------+----------------------------------------------------------------------------+
| Intranet Endpoint | http://166233998075****.cn-shanghai.pai-eas.aliyuncs.com/api/predict/test_eascmd |
| Token | YjhjOWQ2ZjNkYzdiYjEzMDZjOGEyNGY5MDIxMzczZWUzNGEyMzhi**** |
+-------------------+--------------------------------------------------------------------------+
[OK] Creating api gateway
[OK] Building image [registry-vpc.cn-shanghai.aliyuncs.com/eas/test_eascmd_cn-shanghai:v0.0.1-20221122114614]
[OK] Pushing image [registry-vpc.cn-shanghai.aliyuncs.com/eas/test_eascmd_cn-shanghai:v0.0.1-20221122114614]
[OK] Waiting [Total: 1, Pending: 1, Running: 0]
[OK] Waiting [Total: 1, Pending: 1, Running: 0]
[OK] Service is running
References
You can go to the Elastic Algorithm Service (EAS) page to view the deployment status of a model service and manage the model service. For more information, see Model service deployment by using the PAI consoles.
EAS provides multiple deployment methods. You can select a method based on your business requirements. For more information, see Overview.
After you deploy a service, you can use an automatic stress testing tool to test the service performance. For more information, see Automatic stress testing.
If the processors provided by EAS cannot meet your model deployment requirements, you can create a custom processor based on the processor development standards. For more information, see Deploy services by using custom processors.