GCP人工智能平台API



我正在尝试用程序创建"AI平台笔记本;在GCP中。gcloud-sdk确实支持管理这些笔记本电脑,但不支持创建它们。而且没有支持Node.js(我正在使用的语言(的客户端库。但是,如本文所述,GCP REST API支持创建笔记本。然而,我正在努力解决如何在请求的JSON中指定我想要的笔记本。从GCP web UI,我想要的设置是:

  • 实例名称:"测试实例">
  • 区域:";欧洲西部2">
  • 区域:";欧洲西部2a">
  • 环境:";TensorFlow Enterprise 2.1(含"英特尔®;MKL-DNN/MKL"(">
  • 机器类型:";e2-highmem-2(高效实例,2vCPU,16GB RAM(">
  • 访问jupyter实验室:;"仅单个用户">
  • 用户电子邮件:";firstname.surname@email.com">
  • 服务帐户:";team@project.iam.gserviceaccount.com">

但我很难将其转换为REST API的JSON请求。以下是我到目前为止所拥有的。我不确定其中任何一个是正确的,我肯定错过了环境(tensorflow 2.1(和单用户访问。我不知道如何实现这一点,除了随机尝试不同的请求,直到它起作用。(我现在只留下一些JSON,只是根据文档指定类型,以供参考(。

POST https://notebooks.googleapis.com/v1beta1/projects/my-project/locations/europe-west2/instances
{
"name" : "testing-instance",
"instanceOwners": [
string
],
"serviceAccount": "team@project.iam.gserviceaccount.com",
"machineType": "e2-highmem-2 (Efficient Instance, 2 vCPUs, 16 GB RAM)",
"acceleratorConfig": {
object (AcceleratorConfig)
},
"state": enum (State),
"installGpuDriver": boolean,
"customGpuDriverPath": string,
"bootDiskType": enum (DiskType),
"bootDiskSizeGb": string,
"dataDiskType": enum (DiskType),
"dataDiskSizeGb": string,
"noRemoveDataDisk": boolean,
"diskEncryption": enum (DiskEncryption),
"kmsKey": string,
"noPublicIp": boolean,
"noProxyAccess": boolean,
"network": string,
"subnet": string,
"labels": {
string: string,
...
},
"metadata": {
string: string,
...
},
"createTime": string,
"updateTime": string,
// Union field environment can be only one of the following:
"vmImage": {
object (VmImage)
},
"containerImage": {
object (ContainerImage)
}
// End of list of possible types for union field environment.
}

这里是所需的JSON

{
"name": "testing-instance",
"machineType": "zones/europe-west2-a/machineTypes/e2-highmem-2",
"guestAccelerators": [],
"metadata": {
"items": [
{
"key": "proxy-mode",
"value": "mail"
},
{
"key": "framework",
"value": "TensorFlow:2.1"
},
{
"key": "proxy-user-mail",
"value": "firstname.surname@email.com"
}
]
},
"disks": [
{
"boot": true,
"autoDelete": true,
"initializeParams": {
"diskType": "zones/europe-west2-a/diskTypes/pd-standard",
"diskSizeGb": "100",
"sourceImage": "projects/deeplearning-platform-release/global/images/family/tf2-2-1-cu101-notebooks-debian-9"
}
}
],
"scheduling": {
"onHostMaintenance": "MIGRATE"
},
"networkInterfaces": [
{
"subnetwork": "https://www.googleapis.com/compute/v1/projects/gbl-imt-homerider-basguillaueb/regions/europe-west2/subnetworks/datalab-network",
"accessConfigs": [
{
"name": "external-nat",
"type": "ONE_TO_ONE_NAT"
}
]
}
],
"serviceAccounts": [
{
"email": "team@project.iam.gserviceaccount.com",
"scopes": [
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/userinfo.email"
]
}
],
"tags": {
"items": [
"deeplearning-vm"
]
}
}

你们自己猜不出来。我怎么做?使用控制台执行此操作,在提交之前,打开Chorme调试器并捕获网络请求。发布请求包含此JSON!

享受

要使用api创建笔记本实例,这是对我有效的最小json,您可以随时对其进行调整和/或添加!

{
"acceleratorConfig": {},
"installGpuDriver": false,
"machineType": "n1-standard-4",
"name": "apitestinstance3",
"noProxyAccess": false,
"noPublicIp": false,
"vmImage": {
"imageFamily": "tf-2-8-cu113-notebooks-debian-10",
"project": "deeplearning-platform-release"
}
}

最新更新