Friday, April 28, 2017

Instance Template for GPU (Beta) - gcloud command

Hi GCP lovers!

Today I would like to talk about a new functionality that has been made available through the latest Cloud SDK (153.0.0).

Until now, you could create "clusters" of GCE instances by creating Managed Instance Groups (MIG). A MIG uses an Instance Template as base image to scale out.

For heavy load processes like Machine Learning, people use more and more GPU instances. GCP offers GPU instances (currently in beta) with the Nvidia K80 GPU.
Until now, instance template for GPU wasn't available and auto-scaling of instances with GPU couldn't be implemented.

Finally, yesterday, Cloud SDK has been updated to v153.0.0 and includes that functionality:










Please find below an example of glcoud command to create an instance template with GPU (in red, the new flag that has been added to the SDK 153.0.0).

gcloud beta compute instance-templates create gpu-instance-template-1 \
--machine-type n1-standard-2 \
--accelerator type=nvidia-tesla-k80,count=1 \
--image-family ubuntu-1604-lts \
--image-project ubuntu-os-cloud \
--maintenance-policy TERMINATE \
--boot-disk-size 100 \
--boot-disk-type "pd-ssd" \
--restart-on-failure \
--metadata startup-script='#!/bin/bash
    echo "Checking for CUDA and installing."
    # Check for CUDA and try to install.
    if ! dpkg-query -W cuda; then
      curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
      dpkg -i ./cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
      apt-get update
      apt-get install cuda -y
    fi'

Hope it helps!
See you next time :)

2 comments:

  1. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
    google-cloud-platform-training-in-chennai

    ReplyDelete
  2. Pick the template you love for free! We provide a wide collection of web template designs and themes. Check out it now on TemplateMonster.

    ReplyDelete