You can bind an Elastic Acceleration Instance (EAIS) to an ECS instance that is not a GPU-accelerated instance to provide the ECS instance with GPU acceleration, creating a new type of GPU-accelerated instance. Compared to purchasing a GPU-accelerated instance directly, this approach is a flexible and cost-effective way to obtain GPU resources. This topic guides new EAIS users through the complete process of using EAIS to perform inference on a TensorFlow model on an ECS instance.
Background information
This tutorial shows you how to create an eais.ei-a6.2xlarge EAIS instance in the China (Hangzhou) region. It uses the public ResNet-50, Inception, and BERT-Base models as examples to demonstrate performing inference on TensorFlow models with EAIS.
Step 1: Create and bind ECS and EAIS instances
Create an ECS instance.
Log on to the ECS instance creation page.
Create a virtual private cloud (VPC) ECS instance to associate with the EAIS instance.
For more information, see Create an instance.
NoteUse Ubuntu 18.04 as the operating system for the ECS instance.
Create an EAIS instance.
Log on to the EAIS console.
In the left navigation pane, choose Elastic Accelerated Computing Instances EAIS > Elastic Accelerated Computing Instances List.
ImportantIf your Alibaba Cloud account has not been granted the AliyunServiceRoleForEais role, which uses the AliyunServiceRoleForEais access policy, you must first authorize EAIS to create a service-linked role before you can create an EAIS instance. For more information, see Service-linked Role.
Click Create Elastic Accelerated Computing Instance.
On the EAIS instance purchase page, configure the instance parameters and click Buy Now.
The following table describes the configuration items:Configuration item
Example configuration
Region
China (Hangzhou)
Instance name
eais_test
Instance type
eais.ei-a6.2xlarge
Virtual Private Cloud
eais-vpc
vSwitch
eais-vswitch
Security group
eais-securitygroup
Resource group
Default Resource Group
On the Confirm Order page, agree to the Service Agreement by selecting the I have read and agree to the Elastic Accelerated Computing Instances Service Agreement checkbox, and then click Activate Now.

-
Bind the EAIS instance to the ECS instance.
-
Click Console to go to the EAIS console.
Service activation takes 5 to 10 minutes.
-
In the instance list, find the
eais_testinstance and click Bind in the Actions column. -
In the dialog box that appears, select the ECS instance to bind.
-
Click OK.
The instance list automatically refreshes every 15 seconds. When the status of the EAIS instance changes from Binding to Bound, the binding is successful.
ImportantAn EAIS instance can be bound to only one ECS instance, and an ECS instance can be bound to only one EAIS instance. For more information, see Usage Limits.
-
Step 2: Start the EAIS instance
This operation is required only for EAIS instances created using the EAIS console or by calling the CreateEaisEi operation.
In the EAIS instance list, find the
eais_testinstance and click Start in the Actions column.
In the Start Instance dialog box, click OK.
The EAIS instance list auto-refreshes every 15 seconds. When the instance status changes from Associated to In Use, the EAIS instance starts.
Step 3: Log on to the ECS instance
Log on to the EAIS console.
In the EAIS instance list, click the ID of the ECS instance that is associated with the
eais_testinstance to go to the details page of the ECS instance.
Remotely log on to the ECS instance.
For more information, see Select a method for remote connection to an ECS instance.

Step 4: Configure the environment
-
Run the following command to upgrade pip to the latest version:
python3 -m pip install --upgrade pip -
Run the following command to install TensorFlow.
In this example, TensorFlow 1.15.5 is used.
pip3 install tensorflow==1.15.5 -
Run the following command to install eais_tensorflow:
pip3 install eais_tensorflow -f https://aiacc-inference-public.oss-cn-beijing.aliyuncs.com/eais/packages/index.html -
Run the following command to download the model package:
wget https://aiacc-inference-public.oss-cn-beijing.aliyuncs.com/eais/packages/eais2_example.tar -
Run the following command to decompress the package:
tar xvf eais2_example.tar
(Optional) Step 5: View EAIS instance information
After you configure the environment, you can run the eais_smi command to query information about the EAIS instance, such as the instance type and GPU utilization. The following code provides a sample output:
root@ixxx:~# eais_smi
|-------------------------------+----------------------+----------------------|
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 eais.ei-a6.2xlarge On | 00000000:00:07.0 Off | 0 |
| N/A 28C P8 9W / 70W | 0MiB / 15109MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
Step 6: Run TensorFlow model inference
-
Run the following commands to use EAIS to perform inference on the ResNet-50 model:
-
The following output is returned:
average time is 10.636587142944336 ms type: EGYPTIAN CAT -
Run the following commands to use EAIS to perform inference on the Inception model.
In this example, the Inception V4 model is used.
pushd eais2_example/inception python3 inception.py popdThe commands return the following inference result:
average time is 25.059733390808105 ms Results: n02124075 Egyptian cat -
Run the following commands to use EAIS to perform inference on the BERT-Base model:
-
The following output is returned:
100 -- elapse time is: 0.009909868240356445 sec input text: The scenery is beautiful. -> result class is: news_travel
pushd eais2_example/resnet50
python3 resnet50.py
popd
pushd eais2_example/bert
python3 bert_infer.py
popd
(Optional) Step 7: Stop the EAIS instance
You can stop the EAIS instance if you do not temporarily need its GPU capabilities.
This operation is supported only for EAIS instances created using the EAIS console or by calling the CreateEaisEi operation.
Log on to the EAIS console.
In the EAIS instance list, find the
eais_testinstance, and in its Operation column, click Stop.In the Stop Instance dialog box, click OK.
The EAIS instance list auto-refreshes every 15 seconds. A change in the instance status from In Use to Associated indicates that the EAIS instance has stopped.
(Optional) Step 8: Disassociate and release the EAIS instance
After inference is complete, you can disassociate the EAIS instance from the current ECS instance and associate it with another one. If you no longer need the EAIS instance, you must first disassociate it before you can release it. To disassociate and release an EAIS instance, perform the following steps:
Log on to the EAIS console.
Disassociate the EAIS instance from the ECS instance.
In the EAIS instance list, find the
eais_testinstance and click Disassociate in the Operation column.In the Disassociate from ECS Instance dialog box, click OK.
The EAIS instance list auto-refreshes every 15 seconds. When the instance status changes from Associated to Available, the EAIS instance is disassociated.
Release the disassociated EAIS instance.
In the list of EAIS instances, find the
eais_testinstance and click Release Resource in the Operation column.In the Release Resource dialog box, click OK.
The EAIS instance is deleted from the EAIS instance list.
Related documents
You can also learn the complete process of using EAIS to perform inference on a PyTorch model. For more information, see Accelerate PyTorch model inference by using EAIS (Python) or Accelerate PyTorch model inference by using EAIS (C++). For more information about how to use EAIS instances, see Use an EAIS instance or Tutorials.