In scenarios in which graphics computing is not required, such as deep learning and AI, we recommend that you use a GPU-accelerated compute-optimized instance configured with a GPU driver. This topic describes how to create a Linux GPU-accelerated compute-optimized instance configured with a GPU driver that supports automatic installation.
Background information
- You want to purchase a Windows GPU-accelerated instance and a GPU driver. In this case, you must purchase a Windows GPU-accelerated instance that is not configured with a driver and install a GPU driver. For more information, see Create a GPU-accelerated instance that is not configured with a driver and Install a GPU driver on a GPU-accelerated compute-optimized Windows instance.
- You cannot find a public image of the required Linux distribution or version. In this case, you must create a GPU-accelerated instance that is not configured with a GPU driver and install a GPU driver that you purchased from the NVIDIA official website. For more information, see Create a GPU-accelerated instance that is not configured with a driver and Install a GPU driver on a GPU-accelerated compute-optimized Linux instance.
- You want to use a shared image or custom image when you create a GPU-accelerated instance. In this case, you must install a GPU driver after you create the instance.
The installation methods and driver types may vary based on individual use cases. For more information, see Installation guideline for NVIDIA drivers.
Preparations
- Create an Alibaba Cloud account and complete account information.
- Create an Alibaba Cloud account. For more information, see Sign up with Alibaba Cloud.
- Complete real-name verification before you purchase ECS instances in the Chinese mainland. For more information, see Real-name registration FAQs.
- Go to the Custom Launch tab of the instance buy page in the ECS console.
Procedure
Step 1: Complete the settings in the Basic Configurations step
In the Basic Configurations step, you can configure the basic parameters and resources that are required to purchase an instance. The basic parameters include the billing method, region, and zone. The basic resources include the instance type, image, and storage. After you complete the settings in the Basic Configurations step, click Next.
- Select a billing method. The billing method determines how the billing and charging rules are applied to an instance. The billing method also determines how the status of the resources on the instance is changed.
Billing method Description References Subscription You pay for resources before you use them. Subscription Pay-as-you-go You pay for resources after you use them. The billing cycles of pay-as-you-go instances are accurate to the second. You can purchase and release instances based on your business requirements. Note We recommend that you use this billing method together with savings plans to reduce costs.Preemptible Instance You pay for resources after you use them. The price of a preemptible instance is lower than the price of a pay-as-you-go instance. However, the system may release preemptible instances due to fluctuations in the market price or insufficient resources of instance types. Preemptible instances - Select a region and a zone. Select a region that is close to your geographical location to reduce latency. After an instance is created, the region and the zone of the instance cannot be changed. For more information, see Regions and zones.
- Select an instance type and configure the relevant settings.
- Select an image.
- Complete storage settings. ECS instances provide storage capabilities based on the system disks, data disks, and Apsara File Storage NAS file systems that are attached to the instances. ECS provides cloud and local disks to meet the storage requirements of different scenarios.Cloud disks including ESSDs, standard SSDs, and ultra disks and can be used as system disks or data disks. For more information, see Disks.Note A cloud disk that is created along with an instance uses the same billing method as the instance.Local disks can be used only as data disks. For instance families equipped with local disks (such as instance families with local SSDs and big data instance families), the information of the local disks is displayed. For more information, see Local disks.Note Local disks cannot be attached to instances on your own.
- Optional:Configure the snapshot service. You can use automatic snapshot policies to periodically create snapshots to back up disk data and prevent risks such as accidental data deletion.
Select an existing automatic snapshot policy or click Create Automatic Snapshot Policy to create an automatic snapshot policy on the Snapshots page. For more information, see Create an automatic snapshot policy. After an automatic snapshot policy is created, go back to the ECS instance creation wizard and click the icon to query the automatic snapshot policy list.
Step 2: Complete the settings in the Networking step
In the Networking step, you can configure parameters to allow instances to access the Internet and other Alibaba Cloud resources. This ensures the security of your instances. After you complete the settings in the Networking step, click Next.
- Specify parameters in the Network Type and Public IP Address sections.
Parameter Description References Network Type Select VPC. A virtual private cloud (VPC) is a logically isolated virtual network in Alibaba Cloud. You have full control over VPCs that belong to you. For example, you can specify a CIDR block and configure route tables and gateways for the VPC.
If you do not want to use a custom VPC or vSwitch in the specified region when you create an instance, you can skip this operation. Then, the system creates a default VPC and a default vSwitch.Note You can skip this operation only if no available VPCs exist in the region where the instance is deployed.Select an existing VPC and vSwitch. You can also click go to the VPC console to create a VPC and a vSwitch in the VPC console. After the VPC and the vSwitch are created, go back to the ECS instance creation wizard and click the icon to view the VPC and the vSwitch that you created.
Public IP Address If you select an image of Windows 2008 R2 or earlier in the Basic Configurations step, you can select Assign Public IPv4 Address, or you can associate an elastic IP address (EIP) with the instance after the instance is created. This way, you can connect to the instance over other protocols such as the Remote Desktop Protocol (RDP) built into Windows, PC over IP (PCoIP), and XenDesktop HDX 3D. Otherwise, you cannot connect to the instance from a Virtual Network Console (VNC) client after the GPU driver is installed. A persistent black screen or startup interface appears when you attempt to connect to the instance. Note RDP does not support some applications such as DirectX and OpenGL applications. If you want to use these applications, you must manually install the VNC service and client.To assign a public IP address, perform the following operations:- Select Assign Public IPv4 Address.
- Specify the Bandwidth Billing parameter.
- Pay-By-Bandwidth: You are charged based on the specified bandwidth. This billing method is suitable for the scenarios that require stable network bandwidth.
- Pay-By-Traffic: You are charged based on the traffic that you use. You can configure a peak bandwidth value to avoid excessive fees due to sudden traffic spikes. This billing method is suitable for scenarios that require highly variable bandwidth, such as the scenarios where traffic is low in most cases but spikes occasionally occur.
- Set Bandwidth or Peak Bandwidth based on your requirements.
What is EIP? - Select security groups. A security group is a virtual firewall that is used to control the inbound and outbound traffic of instances in the security group. For more information, see Overview.
If you do not want to configure security group-related parameters when you create an instance, you can skip the step. The system creates a default security group. The default security group allows inbound traffic over SSH port 22, Remote Desktop Protocol (RDP) port 3389, and Internet Control Message Protocol (ICMP). You can modify the security group configurations after the security group is created.
- Configure ENIs. ENIs are classified into primary ENIs and secondary ENIs. Primary ENIs cannot be unbound from instances. They cannot be created or released independently of the instances to which they are bound. Secondary ENIs can be bound to or unbound from instances to allow traffic to be switched between instances. To create a secondary ENI when you create an instance, click the icon and select a vSwitch to which to connect the secondary ENI.Note You can bind only one secondary ENI when you create an instance. Alternatively, you can create secondary ENIs and bind them to an instance after the instance is created. For more information about the number of ENIs that can be bound to an instance of each instance type, see Overview of instance families.
Step 3: Complete the settings in the System Configurations step
In the System Configurations step, you can configure the parameters to customize what you want to display for the GPU-accelerated instance in the ECS console and in the OS, and how to use the instance. For example, you can configure the Logon Credentials, Host, and User Data parameters. After you complete the settings in the System Configurations step, click Next.
- Configure logon credentials.
We recommend that you set the Logon Credentials parameter to Key Pair or Password. If you set the Logon Credentials parameter to Set Later, you must bind an SSH key pair or reset the password before you connect to the instance from a management terminal. Then, you must restart the instance so that the logon credentials can take effect. If you restart the instance when the GPU driver is being installed, the GPU driver fails to be installed.
- Specify the instance name and description that you want to display in the ECS console. Specify the hostname that can be obtained from within the operating system. Configure whether to append incremental suffixes to the instance name and hostname. If you want to create multiple instances, you can set sequential instance names and hostnames to facilitate management. For more information about how to configure sequential instance names and hostnames, see Batch configure sequential names or hostnames for multiple instances.
- Configure advanced settings.
Step 4: (Optional) Complete the settings in the Grouping (Optional) step
In the Grouping (Optional) step, you can configure parameters such as Tags and Resource Group for easy search and management. After you complete the settings in the Grouping (Optional) step, click Next.
- Add tags. Each tag consists of a key and a value. You can add tags to resources that have identical characteristics, such as resources that belong to the same organization and resources that serve the same purpose. You can use tags to search for and manage resources in an efficient manner. For more information, see Overview.
Select an existing tag, or enter a key and a value to create a tag.
- Select a resource group from the Resource Group drop-down list. Resource groups allow you to manage resources across regions or across services based on your business requirements and manage the permissions of resource groups. For more information, see Resource groups.
Select an existing resource group, or click click here to create a resource group on the Resource Group page. After a resource group is created, go back to the ECS instance creation wizard and click the icon to query the resource group list. For more information, see Create a resource group.
- Select a deployment set. Deployment sets support the high availability strategy. After you apply the high availability strategy to a deployment set, all the instances in the deployment set are distributed across different physical servers to ensure business availability and implement underlying disaster recovery.
Select an existing deployment set or click manage the deployment set to create a deployment set. After a deployment set is created, go back to the ECS instance creation wizard and click the icon to query the deployment set list. For more information, see Create a deployment set.
- Select a dedicated host. A dedicated host is a cloud host whose physical resources are exclusively reserved for a single tenant. Dedicated hosts meet strict security compliance requirements and support bring your own license (BYOL) when you migrate services to Alibaba Cloud.
Select an existing dedicated host or click create a DDH to create a dedicated host. After the dedicated host is created, go back to the ECS instance creation wizard and click the icon to query the dedicated host list. For more information, see Create a dedicated host.
- Select a private pool. After an elasticity assurance or a capacity reservation is created, the system generates a private pool to reserve resources for a specific number of instances that have specific attributes. During the validity period of the elasticity assurance or capacity reservation, you always have access to the resources reserved in the private pool when you want to create instances. For more information, see Overview.Note Only pay-as-you-go instances can be created from the resources reserved by elasticity assurances or capacity reservations.
Private pool Description Open The capacity in open private pools takes priority over the capacity in the public pool. If no capacity is available in private pools, the system attempts to use the capacity in the public pool. None The capacity in private pools is not used. Targeted The capacity in a specified or open private pool is used to create instances. If no capacity is available in the specified private pool, the instances cannot be created.
Step 5: Complete the settings in the Preview step
Before the instance is created, make sure that all selected settings, such as the usage duration, meet your business requirements.
- Check the selected settings. To modify the settings in a step, click the icon to go to the relevant step. You can generate a template based on the selected settings. Then, you can use the template to create instances that have similar settings. The following table describes the buttons that you can use to generate the template.
Button Description References Save as Launch Template Saves the settings as a launch template. You can use the launch template to create instances without the need to configure the settings again. Create an instance by using a launch template View Open API Generates the API workflow and the SDK sample code for your reference. Save as ROS Template Saves the settings as a Resource Orchestration Service (ROS) template. You can create stacks from the template to deliver resources in an efficient manner. Create a stack - Configure the usage duration of the instance.
- Pay-as-you-go instance or preemptible instance: Specify an automatic release time for the instance. You can also manually release the instance or specify an automatic release time for the instance after the instance is created. For more information, see Release an instance.
- Subscription instance: Specify the usage duration and specify whether to enable auto-renewal. You can also manually renew the instance or enable auto-renewal for the instance after the instance is created. For more information, see Renewal overview.
- Read ECS Terms of Service and Product Terms of Service. If you agree to them, select ECS Terms of Service and Product Terms of Service.
- In the lower part of the page, view the total fees of the instance, confirm the order, and then follow on-screen instructions to complete the payment. If you select Auto-install GPU Driver, the system installs the GPU driver after the instance is created. The installation duration takes about 10 to 20 minutes and varies based on the internal bandwidth and the number of vCPUs provided by different instance types. You can connect to the instance to view the installation process. You can view the installation logs in the /root/auto_install/auto_install.log directory after the GPU driver is installed. The following table describes the display effects during the installation process.
Installation process Display effect In progress The installation progress bar appears. Installed The installation result ALL INSTALL OK appears. Failed The installation result INSTALL FAIL appears. Important When the GPU driver is being installed, the GPU is unavailable. You cannot perform operations or install other GPU-related software on the instance. This prevents an installation failure and ensures instance availability.
Configure an automatic installation script
- You do not want to select Auto-install GPU Driver, Auto-install RDMA Software Stack, AIACC-Training, or AIACC-Inference in the Basic Configurations step, and you want to enter an automatic installation script in the System Configurations step.
- You want to call the RunInstances operation to create a GPU-accelerated instance. In this case, you must upload an automatic installation script by specifying the UserData parameter.
To configure an automatic installation script and use the script to install a GPU driver when you create the instance, perform the following operations:
- Customize an automatic installation script. The automatic installation script contains the following content:
#!/bin/sh #Please input version to install IS_INSTALL_RDMA="" IS_INSTALL_AIACC_TRAIN="" IS_INSTALL_AIACC_INFERENCE="" DRIVER_VERSION="" CUDA_VERSION="" CUDNN_VERSION="" IS_INSTALL_RAPIDS="FALSE" INSTALL_DIR="/root/auto_install" #using .run to install driver and cuda auto_install_script="auto_install.sh" script_download_url=$(curl http://100.100.100.200/latest/meta-data/source-address | head -1)"/opsx/ecs/linux/binary/script/${auto_install_script}" echo $script_download_url mkdir $INSTALL_DIR && cd $INSTALL_DIR wget -t 10 --timeout=10 $script_download_url && sh ${INSTALL_DIR}/${auto_install_script} $DRIVER_VERSION $CUDA_VERSION $CUDNN_VERSION $IS_INSTALL_AIACC_TRAIN $IS_INSTALL_AIACC_INFERENCE $IS_INSTALL_RDMA $IS_INSTALL_RAPIDS
Note The automatic installation script uses the .run installation package to install modules, such as GPU drivers.You must add the following parameters to the script based on your business requirements.- Specify the versions of the GPU driver, CUDA library, and cuDNN library based on the selected instance family and image version. For more information, see Image versions and instance families supported for GPU drivers. Sample code:
DRIVER_VERSION="470.82.01" CUDA_VERSION="11.4.1" CUDNN_VERSION="8.2.4"
- Specify whether to install an RDMA software stack. If you want to install an RDMA software stack, set the IS_INSTALL_RDMA parameter to TRUE. If you do not want to install an RDMA software stack, set the IS_INSTALL_RDMA parameter to FALSE. Sample code:Note You can install RDMA software stacks only when you use instances that belong to the sccgn7ex instance family.
IS_INSTALL_RDMA="TRUE"
- Specify whether to install AIACC-Training and AIACC-Inference.
- If you want to install AIACC-Training, set the IS_INSTALL_AIACC_TRAIN parameter to TRUE. If you do not want to install AIACC-Training, set the IS_INSTALL_AIACC_TRAIN parameter to FALSE.
- If you want to install AIACC-Inference, set the IS_INSTALL_AIACC_INFERENCE parameter to TRUE. If you do not want to install AIACC-Inference, set the IS_INSTALL_AIACC_INFERENCE parameter to FALSE.
Sample code:IS_INSTALL_AIACC_TRAIN="TRUE" IS_INSTALL_AIACC_INFERENCE="FALSE"
- Specify the versions of the GPU driver, CUDA library, and cuDNN library based on the selected instance family and image version. For more information, see Image versions and instance families supported for GPU drivers. Sample code:
- After the script is customized, enter the script in the field below User Data in the Advanced section in the System Configurations step.
After the instance is started, the system installs the GPU driver, CUDA library, and cuDNN library. The system also determines whether to install the RDMA software stack, AIACC-Training, and AIACC-Inference based on the script that you entered. After the installation, the system restarts the instance for the GPU driver to run.
Note The GPU driver in persistence mode is more stable. When you use the automatic installation script, the system enables the persistence mode for the GPU driver in Linux on instance startup. This ensures that the persistence mode is enabled for the GPU driver after the instance is restarted.