Create a GPU function
Deploy GPU-accelerated AI applications—such as Stable Diffusion WebUI, ComfyUI, RAG, and TensorRT—as functions using container images for faster development and delivery.
Create a function
-
Log on to the Function Compute console. In the navigation pane on the left, choose .
-
In the top menu bar, select a region. On the Function List page, click Create Function.
-
In the dialog box that appears, select GPU Function and then click Create GPU Function.
-
On the Create GPU Function page, set the following parameters and then click Create.
-
Basic Configurations: Enter a Function Name. The name must be unique within the same account and region, and must follow the naming conventions.
-
Elastic Configurations: Select an instance type. You cannot mix provisioned and on-demand instances, and the type cannot be changed after creation.
-
On-demand instances
Configuration Item
Description
Example
Instance Type
Select On-demand Instance. Instances scale with request volume and are released when there are no requests. Billed per use.
On-demand Instance
GPU Card Type
Select a GPU card type. Available specifications vary by type (Instance types and specifications).
Ada series
Specifications
Set the GPU Memory, vCPU, Memory, and Disk specifications. Billed by specification × duration (Billing overview).
Note-
All disk directories are writable and share the same space.
-
Disk data is lost on instance reclaim. For persistence, mount a NAS file system (Configure a NAS file system) or an OSS bucket (Configure Object Storage Service).
-
GPU Memory: 48 GB
-
vCPU: 8 vCPU
-
Memory: 64 GB
-
Disk: 512 MB (not billed, Function Compute provides a free quota of 10 GB disk space)
Minimum Instances
For latency-sensitive workloads, select Elastic Instance and set the minimum to 1 or more to reduce cold start latency.
NoteIf no elastic policy is configured or active, the minimum instance count defaults to this value.
With multiple active elastic policies, the highest Minimum Number Of Instances becomes the effective Minimum Number Of Instances.
1
Concurrency Per Instance
Allows a single GPU instance to handle multiple requests concurrently. Configure concurrency per instance.
-
-
Provisioned instances
Configuration Item
Description
Example
Instance Type
Select Provisioned Instance. Instances come from a pre-purchased resource pool.
Best for predictable costs, low latency, and high utilization.
Provisioned Instance
Provisioned Resource Pool
A pre-purchased instance pool for the function. If capacity is insufficient, click Scale-out in the Actions column. Provisioned resource pools (subscription).
-
Provisioned Resource Pool: fc-pool-****
-
GPU Card Type: Ada
Specifications
Set the GPU Memory, vCPU, Memory, and Disk specifications. Billed by specification × duration (Billing overview).
Note-
All disk directories are writable and share the same space.
-
Disk data is lost on instance reclaim. For persistence, mount a NAS file system (Configure a NAS file system) or an OSS bucket (Configure Object Storage Service).
GPU Memory: 48 GB
vCPU: 8 vCPU
Memory: 64 GB
Disk: 512 MB (not billed, Function Compute provides a free quota of 10 GB disk space)
Number Of Provisioned Instances
Allocate instances from the pool's available capacity.
1
Concurrency Per Instance
Allows a single GPU instance to handle multiple requests concurrently. Configure concurrency per instance.
20
-
-
-
Function Code: Configure the function's runtime environment and code.
Configuration Item
Description
Example
Runtime Environment
-
Use Sample Image: Select a Function Compute sample image for quick deployment. Choose the image under Container Image below.
-
Use Image from ACR: Under Container Image, click Select Image From ACR. In the panel, select your Container Registry instance and ACR image repository, then click Select for the target image. Create a function that uses a custom image.
Container Image
Select the target image.
SpringBoot Web Application Sample Image
Startup Command
Startup command. Defaults to the image's Entrypoint/CMD if not specified.
None
Listener Port
The port your HTTP server listens on.
9000
Execution Timeout
Set the timeout. Default Execution Timeout: 60 seconds. Maximum: 86,400 seconds.
60
-
-
Instance Prefetch: Pre-warms the model to eliminate cold start latency for the first request in AI inference scenarios.
Configuration Item
Description
Example
Instance Prefetch
Instance Prefetch
Runs a script or calls an interface to load the model after the instance starts but before it handles requests.
Enabled
Timeout
Timeout for the Initializer hook.
60
Prefetch Program Type
Two hook types: Execute Instruction and Invoke Code.
Execute Instruction
Instruction Content
The instruction to execute. Supports custom shells:
/bin/bash,/bin/sh,/bin/csh,/bin/zsh. Ensure the runtime supports the selected shell. -
Permissions, network, and storage: Configure the function's access role, network, and storage mounts.
Parameter Description Example Function role A RAM role that Function Compute uses to generate temporary credentials for accessing other Alibaba Cloud services. For setup details, see Grant Function Compute permissions to access other Alibaba Cloud services. mytestroleAccess to VPC Enable to allow the function to access resources inside a virtual private cloud (VPC). For configuration details, see Configure a network. Enabled VPC Required when Access to VPC is enabled. Select an existing VPC or create a new one. fc.auto.create.vpc.1632317****vSwitch Required when Access to VPC is enabled. Select an existing vSwitch or create a new one. fc.auto.create.vswitch.vpc-bp1p8248****Security group Required when Access to VPC is enabled. Select an existing security group or create a new one. fc.auto.create.SecurityGroup.vsw-bp15ftbbbbd****Allow default NIC to access internet Controls whether the function can reach the internet through its default network interface controller (NIC). Enabled Mount a NAS file system Mount a NAS file system to persistently share data across functions, such as model files used by multiple inference functions. With automatic configuration, the system uses or creates a General-purpose NAS file system named Alibaba-Fc-V3-Component-Generated. For details, see Configure a NAS file system.Enabled Mount OSS Mount an OSS bucket to persistently store logs, business files, and other data. For details, see Configure Object Storage Service (OSS). Enabled ImportantWhen using a static public IP address, disable Allow default NIC to access internet. Otherwise, the static public IP address does not take effect. For details, see Configure a static public IP address.
-
Log monitoring and tracing
Parameter Description Example Log monitoring Persist function execution logs to Simple Log Service for debugging, fault analysis, and data analytics. Automatic Configuration uses or creates a log project named serverless-<region_id>(one per region). Custom Configuration lets you specify the Log Service Project and Logstore. For details, see Configure the logging feature.Enabled -
More configurations
Parameter Description Example Time zone The time zone for the function. Setting this adds a TZenvironment variable with the selected value.UTCTag Tags for grouping and managing functions. Each tag requires a key and a value. For details, see Function tags. key : valueResource group The resource group the function belongs to. For details, see Resource groups. Default Resource Group Environment variables Key-value pairs injected into the function's execution environment, letting you change function behavior without modifying code. For details, see Configure environment variables. {"BUCKET_NAME": "MY_BUCKET", "TABLE_NAME": "MY_TABLE"}
-
Edit a function
After creation, change the function image on the Configuration tab of the function details page.

Other settings (environment variables, log storage): Configure a function.
Delete a function
-
Log on to the Function Compute console. In the left navigation pane, choose Function Management > Function.
-
Locate the function and click Delete Function in the Actions column.
-
In the confirmation dialog, verify that the function has no attached resources (such as triggers or minimum-instance elastic policies), then confirm the deletion.
Get the ARN of a function
An Aliyun Resource Name (ARN) uniquely identifies an Alibaba Cloud resource and lets you reference functions from code or other services.
-
Log on to the Function Compute console. In the left navigation pane, choose Function Management > Function.
-
In the top menu bar, select a region. Click the target function.
-
On the Function Details page, click Copy ARN on the right.
References
-
Function Compute offers four function types (event, web, task, GPU). Technology selection guide.
-
Beyond the console, Function Compute provides APIs and Serverless Devs for function management. CreateFunction and Quick Start for Serverless Devs.
-
If a function execution times out, see What do I do if a "Function timeout" error occurs?.
-
Infrequently invoked functions may experience longer invocation times (Why do infrequently used functions have long invocation times?). Set the minimum instances to 1 or more to mitigate this.