This page shows you how to create
a TensorFlow Deep Learning VM Images instance
with TensorFlow and other tools pre-installed. You can create
a TensorFlow instance from Cloud Marketplace within
the Google Cloud console or using the command line.

## Before you begin

1. If you are using GPUs with your Deep Learning VM, check the [quotas page](https://console.cloud.google.com/quotas) to ensure that you have enough GPUs available in your project. If GPUs are not listed on the quotas page or you require additional GPU quota, [request a
   quota increase](https://docs.cloud.google.com/compute/quotas#requesting_additional_quota).

## Creating a TensorFlow Deep Learning VM instance from the Cloud Marketplace

To create a TensorFlow Deep Learning VM instance
from the Cloud Marketplace, complete the following steps:

1. Go to the Deep Learning VM Cloud Marketplace page in
   the Google Cloud console.

   [Go to the Deep Learning VM Cloud Marketplace page](https://console.cloud.google.com/marketplace/details/click-to-deploy-images/deeplearning)
2. Click **Get started**.

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

4. Select a **Zone**.

5. Under **Machine type** , select the specifications that you
   want for your VM.
   [Learn more about machine types.](https://docs.cloud.google.com/compute/docs/machine-types)

6. Under **GPUs** , select the **GPU type** and **Number of GPUs** .
   If you don't want to use GPUs,
   click the **Delete GPU** button
   and skip to step 7. [Learn more about GPUs.](https://docs.cloud.google.com/gpu)

   1. Select a **GPU type** . Not all GPU types are available in all zones. [Find a combination that is supported.](https://docs.cloud.google.com/compute/docs/gpus)
   2. Select the **Number of GPUs** . Each GPU supports different numbers of GPUs. [Find a combination that is supported.](https://docs.cloud.google.com/compute/docs/gpus)
7. Under **Framework**, select one of the TensorFlow
   framework versions.

8. If you're using GPUs, an NVIDIA driver is required.
   You can install the driver
   yourself, or select **Install NVIDIA GPU driver automatically
   on first startup**.

9. You have the option to select **Enable access to JupyterLab via URL
   instead of SSH (Beta)**. Enabling this Beta feature lets you
   access your JupyterLab
   instance using a URL. Anyone who is in the Editor or Owner role in your
   Google Cloud project can access this URL.
   Currently, this feature only works in
   the United States, the European Union, and Asia.

10. Select a boot disk type and boot disk size.

11. Select the networking settings that you want.

12. Click **Deploy**.

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

After the VM is deployed, the page updates with instructions for
accessing the instance.

## Creating a TensorFlow Deep Learning VM instance from the command line

To use the Google Cloud CLI to create
a new Deep Learning VM instance,
you must first install and initialize the [Google Cloud CLI](https://docs.cloud.google.com/sdk/docs):

1. Download and install the Google Cloud CLI using the instructions given on [Installing Google Cloud CLI](https://docs.cloud.google.com/sdk/downloads).
2. Initialize the SDK using the instructions given in [Initialize the gcloud CLI](https://docs.cloud.google.com/sdk/docs/initialize).

To use `gcloud` in Cloud Shell, first activate Cloud Shell using the
instructions given on [Starting Cloud Shell](https://docs.cloud.google.com/shell/docs/starting-cloud-shell).

You can create a TensorFlow instance with or without GPUs.

### Without GPUs

To provision a Deep Learning VM instance without a GPU:

    export IMAGE_FAMILY="tf-ent-latest-cpu"
    export ZONE="us-west1-b"
    export INSTANCE_NAME="my-instance"

    gcloud compute instances create $INSTANCE_NAME \
      --zone=$ZONE \
      --image-family=$IMAGE_FAMILY \
      --image-project=deeplearning-platform-release

Options:

- `--image-family` must be one of the following:
  - `tf-ent-latest-cpu` to get the latest [TensorFlow Enterprise](https://docs.cloud.google.com/tensorflow-enterprise/docs) 2 image
  - An earlier TensorFlow or TensorFlow Enterprise image family name (see [Choosing an image](https://docs.cloud.google.com/deep-learning-vm/docs/images))
- `--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](https://docs.cloud.google.com/compute/docs/gpus).

To provision a Deep Learning VM instance with one or more GPUs:

    export IMAGE_FAMILY="tf-ent-latest-gpu"
    export ZONE="us-west1-b"
    export INSTANCE_NAME="my-instance"

    gcloud compute instances create $INSTANCE_NAME \
      --zone=$ZONE \
      --image-family=$IMAGE_FAMILY \
      --image-project=deeplearning-platform-release \
      --maintenance-policy=TERMINATE \
      --accelerator="type=nvidia-tesla-v100,count=1" \
      --metadata="install-nvidia-driver=True"

Options:

- `--image-family` must be one of the following:

  - `tf-ent-latest-gpu` to get the latest [TensorFlow Enterprise](https://docs.cloud.google.com/tensorflow-enterprise/docs) 2 image
  - An earlier TensorFlow or TensorFlow Enterprise image family name (see [Choosing an image](https://docs.cloud.google.com/deep-learning-vm/docs/images))
- `--image-project` must be `deeplearning-platform-release`.

- `--maintenance-policy` must be `TERMINATE`. To learn more, see
  [GPU Restrictions](https://docs.cloud.google.com/compute/docs/gpus#restrictions).

- `--accelerator` specifies the GPU type to use. Must be
  specified in the format
  `--accelerator="type=TYPE,count=COUNT"`.
  For example, `--accelerator="type=nvidia-tesla-v100,count=2"`.
  See the [GPU models
  table](https://docs.cloud.google.com/compute/docs/gpus#other_available_nvidia_gpu_models)
  for a list of available GPU types and counts.

  Not all GPU types are supported in all regions. For details, see
  [GPU regions and zones availability](https://docs.cloud.google.com/compute/docs/gpus/gpu-regions-zones).
- `--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.

### About TensorFlow Enterprise

[TensorFlow Enterprise](https://docs.cloud.google.com/tensorflow-enterprise/docs) is a
distribution of
[TensorFlow](https://www.tensorflow.org/)
that has been optimized to run on Google Cloud and includes
[Long Term Version
Support](https://docs.cloud.google.com/tensorflow-enterprise/docs/overview#long_term_version_support).

## 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 stop (preempt) these
instances if it requires access to those resources for other tasks.
Preemptible instances always stop after 24 hours. To learn more about
preemptible instances, see [Preemptible VM
Instances](https://docs.cloud.google.com/compute/docs/instances/preemptible).

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 Google Cloud console or command line, see [Connecting to
Instances](https://docs.cloud.google.com/compute/docs/instances/connecting-to-instance). Your instance name
is the **Deployment name** you specified with `-vm` appended.