Cloud Marketplace lets you quickly deploy functional software
packages that run on Compute Engine. A Deep Learning VM with
PyTorch can be created quickly from the Cloud Marketplace
within the GCP Console without having to use the command line.

Enter a Deployment name which will be the root of your VM name.
Compute Engine appends -vm to this name when naming your
instance.

Set Framework to PyTorch and choose Zone.

Choose your GPU type. Not all GPU types are available in all zones;
see the GPUs on Compute Engine page to confirm that
your combination is supported.

Choose the number of GPUs to deploy. Each GPU supports different numbers;
see the GPUs on Compute Engine page to confirm that
your combination is supported.

An NVIDIA driver is required when using GPUs. You can install the driver
yourself, or select the checkbox to have the latest stable driver installed
automatically.

Follow the instructions on the page to check your GPU quota, and enter
the required phrase to confirm.

In the CPU section, adjust your machine type as needed. For certain
workflows, you may want to increase the number or cores (e.g. for
CPU-heavy preprocessing) or the amount of memory (e.g. using CPU as a
parameter store for distributed training).

Click Deploy.

If you've elected to install NVIDIA drivers, allow 3-5 minutes for installation
to complete.

Once the VM has been deployed, the page will update with instructions for
accessing the instance.

Creating a PyTorch Deep Learning VM instance from the command line

To use the gcloud command-line tool to create a new a Deep Learning VM
instance, you must first install and initialize the Cloud SDK:

--image-family must be either pytorch-latest-cpu
or pytorch-VERSION-cpu (for example,
pytorch-0-4-cpu).

--image-project must be deeplearning-platform-release.

With one or more GPUs

Compute Engine offers the option of adding one or more GPUs to your
virtual machine instances. GPUs offer faster processing for many complex data
and machine learning tasks. To learn more about GPUs, see GPUs on
Compute Engine.

To create a Deep Learning VM with the latest PyTorch instance and one
or more attached GPUs, enter the following at the command line:

--metadata is used to specify that the NVIDIA driver should be installed
on your behalf. The value is install-nvidia-driver=True. If specified,
Compute Engine loads the latest stable driver on the first boot
and performs the necessary steps (including a final reboot to activate the
driver).

If you've elected to install NVIDIA drivers, allow 3-5 minutes for installation
to complete.

It may take up to 5 minutes before your VM is fully provisioned. In this
time, you will be unable to SSH into your machine. When the installation is
complete, to guarantee that the driver installation was successful, you can
SSH in and run nvidia-smi.

When you've configured your image, you can save a snapshot of your
image so that you can start derivitave instances without having to wait
for the driver installation.

Creating a preemptible instance

You can create a preemptible Deep Learning VM instance. A preemptible
instance is an instance you can create and run at a much lower price than
normal instances. However, Compute Engine might terminate (preempt) these
instances if it requires access to those resources for other tasks.
Preemptible instances will always terminate after 24 hours. To learn more about
preemptible instances, see Preemptible VM
Instances.

To create a preemptible Deep Learning VM instance:

Follow the instructions located above to create a new instance using the
command line. To the gcloud compute instances create command, append the
following:

--preemptible

What's next

For instructions on connecting to your new Deep Learning VM instance
through the GCP Console or command line, see Connecting to
Instances. Your instance name
is the Deployment name you specified with -vm appended.