morepenguins
morepenguins

Reputation: 1277

Removing a GPU from Existing Virtual Machine in GCP

I am trying to remove a GPU from a Virtual Machine in Google Cloud. Right now the VM is set as an A2 Series, but I'd like to switch to a GPU-free E2 machine.

I have been following the instructions here, however the Edit VM interface will not allow me to "x" out GPUs or to select less than one GPU.

As a result I keep getting this error when attempting to switch to an E2:

Operation type [setMachineResources] failed with message "Accelerator optimized instances must be attached with A100 GPUs."

After attempts at fixing...

Following @Ferregina Pelona's answers, if I try running the following from the cloud shell:

gcloud compute instances set-machine-type INSTANCE_NAME --zone=ZONE --machine-type=e2-micro

Then I get the following error:

- e2 instances do not support onHostMaintenance=TERMINATE unless they are preemptible.

However the GUI also throws a bug if I try to change onHostMaintenance to migrate there.

If I try to change it from the command line (Thanks @Ferregina for your suggestions!):

gcloud compute instances set-scheduling INSTANCE_NAME --zone=ZONE  --maintenance-policy=MIGRATE

Then I get the following error:

ERROR: (gcloud.compute.instances.set-scheduling) Could not fetch resource:  - Instances with guest accelerators do not support live migration.

Is there any way to set-machine-type and set-scheduling simultaneously?

Upvotes: 1

Views: 2598

Answers (3)

Grzenio
Grzenio

Reputation: 36639

It actually may be easiest to delete your Instance and create a new one. Stopping an instance actually deletes the VM, so there should be little difference.

If you need to keep you persistent disks, then you can mark them as autoDelete=false, and attach to the new Instance on creation. If you need to keep your IP, then you can create a reservation in a similar fashion.

Upvotes: 1

rriovall
rriovall

Reputation: 486

per this public document "If your VM does not have a local SSD and is not part of a managed instance group (MIG), you can change the machine type of your VM after stopping it."

And then checking at the Machine family comparison, looks like machine family A2 uses local SSD therefore it could not be possible because if your VM has a local SSD, you cannot stop the VM to change its machine type unless you force it to stop, which causes you to lose all of the data on the local SSD.

Upvotes: 1

Puteri
Puteri

Reputation: 3789

There is some kind of glitch with the UI when changing from the A-series to a "normal" instance so you may want to report this here. Being more specific, is about the request the UI sends to the GCE API which seems to contain the new intance type but also the GPU; this is not a valid configuration.

As a workaround may want to change the instance type using the gcloud command:

gcloud compute instances set-machine-type INSTANCE_NAME --zone=ZONE --machine-type=e2-micro

EDIT

Because the gcloud commands are not useful because the operations are split (IMO a very bad design of the commands), you may want to go with these steps. Those basically download the configuration file for the instance, then change the instance type and the scheduling and apply the changes.

Upvotes: 1

Related Questions