CreateInstance

更新时间:
复制 MD 格式

CreateInstance creates a DSW instance.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request syntax

POST /api/v2/instances HTTP/1.1

Request parameters

Parameter

Type

Required

Description

Example

body

object

No

The properties of the instance.

WorkspaceId

string

No

The ID of the workspace. To obtain the workspace ID, see ListWorkspaces.

40823

InstanceName

string

No

The instance name. The name must meet the following requirements:

  • Can contain only letters, digits, and underscores (_).

  • Cannot be longer than 27 characters.

training_data

EcsSpec

string

No

The ECS instance type. For a list of available instance types, see ListEcsSpecs.

ecs.c6.large

ImageId

string

No

The ID of the image. For a list of available images, see ListImages.

image-05cefd0be2exxxx

ImageUrl

string

No

The URL of the image. Call the ListImages operation to obtain the URL.

registry.cn-shanghai.aliyuncs.com/pai_product/tensorflow:py36_cpu_tf1.12_ubuntu

Datasets

array<object>

No

The datasets to mount to the instance.

object

No

A dataset.

DatasetId

string

No

The ID of the dataset. If a dataset is read-only, you cannot use theMountAccess parameter to change the access mode to read/write.

To obtain the dataset ID, see ListDatasets. This parameter is mutually exclusive withUri.

d-vsqjvs****rp5l206u

DatasetVersion

string

No

The version of the dataset. You must also specify theDatasetId parameter. If this parameter is omitted, the default is v1.

v1

Uri

string

No

The URI of the storage service directory for direct mounting. This parameter is mutually exclusive withDatasetId.

The following list describes the URI formats for different storage types:

  • OSS: oss://bucket-name.oss-cn-shanghai-internal.aliyuncs.com/data/path/

  • NAS: nas://29**d-b12****446.cn-hangzhou.nas.aliyuncs.com/data/path/

  • Extreme NAS: nas://29****123-y**r.cn-hangzhou.extreme.nas.aliyuncs.com/data/path/

  • CPFS: cpfs://cpfs-213****87.cn-wulanchabu/ptc-292*****cbb/exp-290********03e/data/path/

  • Lingjun CPFS: bmcpfs://cpfs-290******foflh-vpc-x****8r.cn-wulanchabu.cpfs.aliyuncs.com/data/path/

oss://bucket-name.oss-cn-shanghai-internal.aliyuncs.com/data/path/

MountPath

string

No

The mount path of the dataset.

/mnt/data

MountAccess

string

No

The read/write permissions for the mounted dataset. If the source dataset is read-only, you cannot grant read/write permissions.

Valid values:

  • RW :

    Read/write

  • RO :

    Read-only

RW

Options

string

No

Specifies custom mount properties. This parameter is supported for OSS datasets only. This parameter is mutually exclusive withOptionType. For more information, see Configure DSW mounting.

{ "fs.oss.download.thread.concurrency": "10", "fs.oss.upload.thread.concurrency": "10", "fs.jindo.args": "-oattr_timeout=3 -oentry_timeout=0 -onegative_timeout=0 -oauto_cache -ono_symlink" }

OptionType deprecated

string

No

The mount type. This parameter is deprecated and mutually exclusive with Options. We recommend that you use the Options parameter instead.

ReadOnly

Dynamic

boolean

No

Specifies whether to enable dynamic mounting. Default value: false.

  • This feature is supported only for instances that use general-purpose computing resources.

  • Only OSS datasets are supported. Mounted datasets are read-only.

  • The mount path of a dynamically mounted dataset must be a subdirectory of the dynamic mount root path. The default root path is/mnt/dynamic/. Example:/mnt/dynamic/data1/.

  • Dynamically mounted datasets must be specified after non-dynamically mounted datasets.

true

UserVpc

object

No

The user VPC configurations.

VpcId

string

No

The VPC ID.

vpc-xxxxx

VSwitchId

string

No

The vSwitch ID.

vsw-xxxxx

SecurityGroupId

string

No

The ID of the security group.

sg-xxxxxx

ExtendedCIDRs

array

No

The extended CIDR blocks.

  • If you do not specify a vSwitch ID, this parameter is optional. The system automatically obtains all CIDR blocks for the VPC.

  • If you specify a vSwitch ID, this parameter is required. We recommend that you specify all CIDR blocks for the VPC.

["192.168.0.1/24", "192.168.1.1/24"]

string

No

An extended CIDR block.

"172.16.19.0/24","172.16.2.0/24","172.16.12.0/24"

DefaultRoute

string

No

The default route. Valid values:

eth0

ForwardInfos

array

No

The port forwarding configurations.

ForwardInfo

No

A port forwarding configuration. You can configure parameters such as the mapped port, gateway ID, and SSH public key.

BandwidthLimit

BandwidthLimit

No

Accessibility

string

No

The visibility of the instance.

Valid values:

  • PUBLIC :

    Visible to all users in the workspace.

  • PRIVATE :

    Visible only to the instance owner and workspace administrators.

PRIVATE

EnvironmentVariables

object

No

The environment variables to inject into the DSW instance.

Warning These variables may overwrite preset system environment variables.

{userName: "Chris"}

string

No

A user-defined environment variable. After the DSW instance starts, the system injects this variable into the container.

MAAS

ResourceId

string

No

The ID of the resource group. This parameter is required for subscription instances. To learn how to create a dedicated resource group, see Prepare and manage DLC resource groups.

dsw-123456789

Priority

integer

No

The priority of the instance for resource allocation. Instances with higher priorities are given precedence. Valid values: 1 to 9.

  • 1: The lowest priority.

  • 9: The highest priority.

1

RequestedResource

object

No

The resource configuration.

{"CPU":"4","Memory":"8Gi","SharedMemory":"4Gi","GPU":"1","GPUType":"Tesla-V100-16G"}

CPU

string

No

The number of CPU cores.

32

Memory

string

No

The memory size. Unit: GiB.

Important You must specify a unit, such as 32Gi. If you omit the unit, the system defaults to MiB.

32GB

SharedMemory

string

No

The shared memory size. Unit: GiB.

Important You must specify a unit, such as 32Gi. If you omit the unit, the system defaults to MiB.

32GB

GPU

string

No

The number of GPUs.

4

GPUType

string

No

The GPU type. Valid values:

  • V100

  • A100

  • T4

  • A10

  • P100

v100

Labels

array<object>

No

The list of custom tags.

{'foo': 'bar'}

object

No

A custom tag.

Key

string

No

The key of the custom tag.

stsTokenOwner

Value

string

No

The value of the custom tag.

123xxxxxxxx

CloudDisks

array<object>

No

The list of cloud disks.

[]

array<object>

No

A cloud disk.

Capacity

string

No

If you use public resources or subscription general-purpose computing resources (with at least 2 CPU cores and 4 GiB of memory, or with a GPU):

Each instance comes with a complimentary 100 GiB system disk for persistent storage. If the instance is stopped for more than 15 days, data on the cloud disk is deleted. You can expand the cloud disk capacity. For pricing details, see the page in the console.

Warning
  • You cannot shrink the disk after expansion. Plan your capacity needs accordingly.

  • After you expand the disk, the 15-day data deletion policy for stopped instances no longer applies. However, billing continues for the entire disk capacity.

  • The system disk is deleted when the instance is deleted. Be sure to back up your data before deleting the instance.

If you require permanent storage, you can configure dataset mounting or add an OSS, NAS, or CPFS path in the storage path mounting settings.

100Gi

SubType

string

No

The type of the cloud disk:

  • rootfs: The disk is mounted as a system disk, which stores the system environment.

rootfs

MountPath

string

No

The mount path of the cloud disk.

/mnt/systemDisk

Path

string

No

The subpath on the cloud disk to mount to the instance.

workspace

Status

object

No

The usage status of the cloud disk or snapshot.

Available

integer

No

The available space, in bytes.

31841058816

Usage

integer

No

The used space, in bytes.

371195904

Capacity

integer

No

The total capacity, in bytes.

32212254720

WorkspaceSource

string

No

Specifies the storage for the working directory (/mnt/workspace). You can mount a cloud disk or a dataset. OSS datasets and dynamically mounted datasets are not supported.

You can specify one of the following:

  • rootfsCloudDisk: Mounts the cloud disk to the working directory.

  • The mount path of a dataset in theDatasets parameter, such as/mnt/data. This is the only way to specify the working directory for datasets in URI format.

  • The ID of a dataset, such asd-vsqjvs****rp5l206u. If the same dataset is mounted to multiple paths, the system uses the first mount path. We recommend that you use the mount path instead of the dataset ID.

If this parameter is left empty:

  • If the instance uses a cloud disk, the cloud disk is used by default.

  • If the instance does not use a cloud disk, the first NAS or CPFS dataset is used as the working directory.

  • If the instance has neither a cloud disk nor a NAS or CPFS dataset, the host machine's local storage is used.

rootfsCloudDisk

UserId

string

No

The account ID of the instance owner. This can be an Alibaba Cloud account ID or a RAM user ID.

161228528250****

Driver

string

No

The NVIDIA driver configuration.

535.54.03

CredentialConfig CredentialConfig

No

The credential configuration.

Affinity

object

No

The affinity configuration.

CPU

object

No

The CPU affinity configuration. This feature is supported only for subscription instances that use general-purpose computing resources.

Enable

boolean

No

Specifies whether to enable CPU affinity.

  • false: disabled.

  • true: enabled.

true

ImageAuth

string

No

The Base64-encoded username and password for a private image. The password is hidden in the response.

****

DynamicMount DynamicMount

No

The dynamic mounting configuration.

Tag

array<object>

No

The list of tags.

object

No

A tag.

Key

string

No

The key of the tag.

tag1

Value

string

No

The value of the tag.

value1

UserCommand

object

No

The user-defined commands.

OnStart

object

No

A custom command that runs every time the instance starts. The system executes the command after initializing the instance environment and before services such as JupyterLab and Code-Server start.

Content

string

No

The content of the custom startup command.

OversoldType

string

No

The type of the preemptible resource. Valid values:
ForceQuotaOverSold: Use only preemptible resources.
AcceptQuotaOverSold: Accept preemptible resources.
ForbiddenQuotaOverSold: Use guaranteed resources.


AssignNodeSpec

object

No

The node scheduling configuration.

NodeNames

string

No

A comma-separated list of node names to schedule the instance on. Example: "node-a,node-b".

node-a

AntiAffinityNodeNames

string

No

A comma-separated list of nodes where the instance should not be scheduled. Example: "node-a,node-b".

node-b

SpotSpec

object

No

The configurations for the spot instance.

SpotStrategy

string

No

The preemption strategy. Valid values:
SpotWithPriceLimit: Set a custom maximum hourly price for the spot instance.
SpotAsPriceGo: The system automatically bids based on the real-time market price.

SpotWithPriceLimit

SpotPriceLimit

string

No

The maximum hourly price for the spot instance, with up to three decimal places. This parameter is required if SpotStrategy is set to SpotWithPriceLimit.

0.12

SpotDuration

string

No

The protection period of the spot instance, in hours. The default value is 1. A value of 0 indicates no protection period. This parameter is invalid for Lingjun instances.

0

SpotDiscountLimit

string

No

The maximum hourly discount for the spot instance. This parameter is required for Lingjun instances.

0.1

DockerConfig

object

No

Enable

boolean

No

ContainersLimit

integer

No

10

MountAccessConfigPath

string

No

MigrationOptions

object

No

AccessRestrictionRules

object

No

string

No

Response elements

Element

Type

Description

Example

object

The response data.

RequestId

string

The request ID.

E7D55162-4489-1619-AAF5-3F97D5FCA948

Success

boolean

Indicates whether the request was successful. Possible values:

  • true

  • false

true

Message

string

The response message.

"XXX"

Code

string

The status code. Possible values:

  • InternalError: An internal error. This code is returned for any error except a parameter validation error.

  • ValidationError: A parameter validation error.

null

HttpStatusCode

integer

The HTTP status code. Possible values:

  • 400

  • 404

  • 200

200

InstanceId

string

The instance ID.

dsw-730xxxxxxxxxx

Examples

Success response

JSON format

{
  "RequestId": "E7D55162-4489-1619-AAF5-3F97D5FCA948",
  "Success": true,
  "Message": "\"XXX\"",
  "Code": "null",
  "HttpStatusCode": 200,
  "InstanceId": "dsw-730xxxxxxxxxx"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.