Upgrade instance with a GPU from gcloud command

217 views
Skip to first unread message

Insharp Lotus

unread,
Aug 30, 2017, 1:52:23 AM8/30/17
to Google App Engine, cham...@gmail.com

I have a instance that I can upgrade and downgrade machine type from gcloud command. For example I can do

gcloud compute instances set-machine-type instance-name --machine-type f1-micro

to downgrade a existing instance and

gcloud compute instances set-machine-type ubuntu --machine-type n1-standard-1

to upgrade the machine type. But I need to also attach an GPU when when I upgrade. I can do that on web interface but I need to do this on command line. How can I do that?

Thanks.

Navi Aujla (Google Cloud Support)

unread,
Aug 30, 2017, 12:45:11 PM8/30/17
to Google App Engine, cham...@gmail.com
Hello, 

Currently, it is not possible to attach GPU to an existing instance using "gcloud" command. You can attach GPU using cloud console, "EDIT" option of the instance when it is in the stop state. Another way to attach GPU to an existing instance (stopped) is through API [1][2]. 

Following is the URL which needs to be defined for property guestAccelerators[].acceleratorType:

https://www.googleapis.com/compute/beta/projects/<project-id>/zones/<zone-where-instance-is-deployed>/acceleratorTypes/nvidia-tesla-k80

Example: https://www.googleapis.com/compute/beta/projects/test-project/zones/us-west1-b/acceleratorTypes/nvidia-tesla-k80

You can submit a feature request at public issue tracker [3] to add a parameter for "gcloud" to attach GPU to an existing instance. 

[1] https://developers.google.com/apis-explorer/#search/compute%20engine/compute/v1/compute.instances.setMachineResources
[2] https://cloud.google.com/compute/docs/reference/beta/instances/setMachineResources
[3] https://issuetracker.google.com

Insharp Lotus

unread,
Aug 31, 2017, 3:21:26 AM8/31/17
to Google App Engine, cham...@gmail.com
Thanks Navi.

I wrote a script to attach GPU with your API reference and it works for attaching a GPU, thanks.

Do you know any way to detach the GPU from a API request. Surfed the documentation but could not find anything. I tried adding 0 to "acceleratorCount" parameter but it says 

"Invalid value for field 'guestAccelerators[0].acceleratorCount': '0'. Number of accelerator cards attached to an instance must be one of [1, 2, 4, 8]."

Navi Aujla (Google Cloud Support)

unread,
Aug 31, 2017, 11:26:38 AM8/31/17
to google-a...@googlegroups.com, cham...@gmail.com
Thanks for your message. 

I experienced the same error "Invalid value for field 'guestAccelerators[0].acceleratorCount': '0'. Number of accelerator cards attached to an instance must be one of [1, 2, 4, 8]." when I used "0" count for the field "accelratorCount".  Currently, It does not seem possible to remove GPU from an existing instance using 'gcloud' or using API. 

I would suggest you to file a feature request at public issue tracker [1] to add the feature of removing GPU from an existing instance using API. 

Insharp Lotus

unread,
Sep 1, 2017, 12:46:11 AM9/1/17
to Google App Engine, cham...@gmail.com
Just published the issue https://issuetracker.google.com/65267943

Thanks.

Navi Aujla (Google Cloud Support)

unread,
Sep 1, 2017, 10:33:47 AM9/1/17
to Google App Engine, cham...@gmail.com
Thank you for filing feature-request/issue on Public issue tracker.  I have forwarded this issue/feature-request to the backend team. You can track this thread to post any further comments or check the updates regarding this feature request/issue. However we can't provide you with any ETA at this point.
Reply all
Reply to author
Forward
0 new messages