Skip to Content
GPU 接口文档GPU实例获取可用机型列表
GPU API 接口

获取可用机型列表

接口说明

获取指定地域下可售/售罄的所有 GPU 机型信息,包括每种机型的 CPU/内存/GPU 合法组合、磁盘类型、CPU 平台等。创建实例前可调用此接口确认可用配置。

POSThttps://api.compshare.cnActionDescribeAvailableCompShareInstanceTypes

请求参数

名称类型必填描述示例值
ActionString接口名称DescribeAvailableCompShareInstanceTypes
RegionString地域cn-wlcb
ZoneString可用区cn-wlcb-01
MachineTypesArray of String按机型名称数组筛选["4090"]
InstanceTypeString实例类型。枚举值:uhost(普通实例,默认)、spot(抢占式实例)uhost

响应参数

名称类型描述示例值
ActionString响应名称DescribeAvailableCompShareInstanceTypesResponse
RetCodeInteger返回码,0 为成功0
AvailableInstanceTypesArray of Object可用机型列表

AvailableInstanceTypes 元素字段

名称类型描述
NameString机型名称(即 GpuType),如 4090A800
ZoneString可用区
StatusString售卖状态。枚举值:Normal(可售)、SoldOut(售罄)
DescriptionString机型描述
MachineSizesArray of MachineSizeGPU 数量与对应的 CPU/内存组合
CpuPlatformsCpuPlatforms支持的 CPU 平台,按厂商分组
DisksArray of AvailableDisk支持的磁盘类型及约束
GraphicsMemoryGraphicsMemory显存信息
PerformanceObject性能评级,含 Value(分值)和 Rate(星级)
MachineClassString机器类别,当前为 GPU
ParentTypeString父机型,当前为 G

CpuPlatforms 结构

按 CPU 厂商分组的平台列表,不是数组,而是对象

名称类型描述
IntelArray of StringIntel 平台列表,如 ["Intel/IceLake"]
AmdArray of StringAMD 平台列表,如 ["Amd/EPYC3", "Amd/EPYC2"]

某些机型可能只有 Intel 或只有 Amd 字段。

GraphicsMemory 结构

名称类型描述
ValueInteger显存大小(GB)
RateInteger显存评级

MachineSize 结构

名称类型描述
GpuIntegerGPU 卡数
CollectionArray of Object该卡数下可选的 CPU/内存组合

Collection 元素:

名称类型描述
CpuIntegerCPU 核数
MemoryArray of Integer可选的内存值列表,单位为 GB(注意:CreateCompShareInstance 等接口的 Memory 参数使用 MB)
MinimalCpuPlatformArray of String该组合支持的 CPU 平台列表

AvailableDisk 结构

名称类型描述
NameString磁盘组名称,如 cloudDisk
BootDiskArray of DiskType支持的系统盘类型
DataDiskArray of DiskType支持的数据盘类型

DiskType 元素:

名称类型描述
NameString磁盘类型,如 CLOUD_SSDCLOUD_RSSD
InstantResizeBoolean是否支持在线扩容
MinimalSizeInteger最小容量(GB),系统盘可能无此字段
MaximalSizeInteger最大容量(GB)
FeaturesArray of String支持的特性,如 SNAPSHOTDATAARK

请求示例

Python(使用 UCloud SDK)

from ucloud.core import exc from ucloud.client import Client def main(): client = Client({ "region": "cn-wlcb", "public_key": "my_public_key", # 替换为你的公钥(控制台 账户中心 → API 密钥:https://console.compshare.cn/uaccount/api_manage) "private_key": "my_private_key", # 替换为你的私钥 "base_url": "https://api.compshare.cn", }) try: resp = client.ucompshare().describe_available_comp_share_instance_types({ "Zone": "cn-wlcb-01", }) for t in resp.get("AvailableInstanceTypes", []): print(f" {t['Name']} - {t['Status']}") except exc.UCloudException as e: print(e) if __name__ == "__main__": main()

Go(使用 UCloud SDK)

package main import ( "fmt" "github.com/ucloud/ucloud-sdk-go/services/ucompshare" "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) func main() { cfg := ucloud.NewConfig() cfg.Region = "cn-wlcb" cfg.Zone = "cn-wlcb-01" cfg.BaseUrl = "https://api.compshare.cn" credential := auth.NewCredential() credential.PublicKey = "my_public_key" // 替换为你的公钥(控制台 账户中心 → API 密钥:https://console.compshare.cn/uaccount/api_manage) credential.PrivateKey = "my_private_key" // 替换为你的私钥 client := ucompshare.NewClient(&cfg, &credential) req := client.NewDescribeAvailableCompShareInstanceTypesRequest() resp, err := client.DescribeAvailableCompShareInstanceTypes(req) if err != nil { fmt.Printf("查询失败: %s\n", err) return } for _, t := range resp.AvailableInstanceTypes { fmt.Printf(" %s - %s\n", t.Name, t.Status) } }

响应示例

{ "Action": "DescribeAvailableCompShareInstanceTypesResponse", "RetCode": 0, "AvailableInstanceTypes": [ { "Name": "4090", "Zone": "cn-wlcb-01", "Status": "Normal", "Description": "RTX40系", "CpuPlatforms": { "Intel": ["Intel/IceLake"], "Amd": ["Amd/EPYC3", "Amd/EPYC2"] }, "Disks": [ { "Name": "cloudDisk", "BootDisk": [ {"Name": "CLOUD_SSD", "InstantResize": true, "MaximalSize": 1000, "Features": ["SNAPSHOT"]} ], "DataDisk": [ {"Name": "CLOUD_SSD", "MinimalSize": 10, "MaximalSize": 1500, "Features": ["SNAPSHOT"]} ] } ], "MachineSizes": [ { "Gpu": 1, "Collection": [ {"Cpu": 16, "Memory": [64, 94], "MinimalCpuPlatform": ["Amd/Epyc2", "Amd/Epyc3", "Intel/IceLake"]} ] }, { "Gpu": 2, "Collection": [ {"Cpu": 32, "Memory": [128, 192], "MinimalCpuPlatform": ["Amd/Epyc2", "Amd/Epyc3", "Intel/IceLake"]} ] } ], "GraphicsMemory": {"Value": 24, "Rate": 3}, "Performance": {"Value": 83, "Rate": 3}, "MachineClass": "GPU", "ParentType": "G" } ] }

单位注意Memory 字段的值单位为 GB。创建实例(CreateCompShareInstance)和价格查询(GetCompShareInstancePrice)等接口的 Memory 参数单位为 MB,需要进行转换(如 64 GB = 65536 MB)。

Last updated on