Score:0

How to launch a marketplace image (colab) on a Spot instance?

me flag

Let's say there's a marketplace image, e.g. Colab. I want to launch it on a GCE spot instance. When I use the Deployment Manager, there is no option to choose the spot provisioning model.
Neither documentation nor googling helps. Is there a way to launch a marketplace image on a spot instance?

Score:1
me flag

I managed to extract the cloud init configuration and properties from an instance created by the marketplace and deployment manager. I posted it on gist. Let me know if you know a better solution.

Here's the gcloud command to launch a spot instance with Colab image and cloud init configuration. The setup happens in cloud_init.conf, see the gist above.

gcloud beta compute instances create colab-1-vm \
--machine-type=e2-highmem-4 \
--provisioning-model=SPOT \
--boot-disk-size=200GB \
--boot-disk-type=pd-balanced \
--instance-termination-action=DELETE \
--image=https://www.googleapis.com/compute/v1/projects/colab-marketplace-image-public/global/images/colab-mp-20220110 \
--network=https://www.googleapis.com/compute/v1/projects/<INSERT_PROJECT_ID>/global/networks/default \
--subnet=https://www.googleapis.com/compute/v1/projects/<INSERT_PROJECT_ID>/regions/<INSERT_REGION>/subnetworks/default \
--no-restart-on-failure \
--metadata-from-file=user-data=cloud_init.conf \
--service-account=<INSERT_ACCOUNT>@developer.gserviceaccount.com \
--scopes=https://www.googleapis.com/auth/cloud.useraccounts.readonly,https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/cloudruntimeconfig,https://www.googleapis.com/auth/compute
Score:0
hm flag

As an addition to Alexandrs contribution, I added support for a GPU in this forked gist.

Score:0
ng flag

Create Spot VMs using the gcloud tool or the Compute Engine API. Spot VMs are any VMs that are configured to use the spot provisioning model: --provisioning-model=SPOT in the gcloud tool or "provisioningModel": "SPOT" in the Compute Engine API.

Please refer to the documents about how to Create Spot VMs on GCP.

After connecting to the server using,

$ gcloud compute ssh --zone us-central1-a 'instance-name' -- -L 8888:localhost:8888

Install and set up the necessary libraries to connect to a Colab frontend by using the following command:

$ pip install jupyter_http_over_ws jupyter serverextension enable --py jupyter_http_over_ws jupyter notebook  
--NotebookApp.allow_origin='https://colab.research.google.com' --port=8888 --NotebookApp.port_retries=0 --no-browser

To connect to a Colab frontend, we get an URL as an output of the above command.

When you click the URL’s in the terminal it will redirect to the Jupyter home page successfully without any problems.

Refer Colab+GCP Compute — how to link them together for more information.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.