# Create a Deep Learning VM instance by using the gcloud CLI

This page shows you how to create a Deep Learning VM Images instance
by using the Google Cloud CLI.

## Before you begin

To use the Google Cloud CLI for this quickstart, 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 for this quickstart, first activate
Cloud Shell using the instructions given on [Starting Cloud
Shell](https://docs.cloud.google.com/shell/docs/starting-cloud-shell).

## Create a new instance

These instructions create a Deep Learning VM instance with the
following parameters:

- Using a TensorFlow on CUDA 9.2 [image](https://docs.cloud.google.com/deep-learning-vm/docs/images): `tf-latest-cu92`.
- In the US West1-B [zone](https://docs.cloud.google.com/compute/docs/gpus): `us-west1-b`.
- Named `my-new-instance`.
- Of the [instance type](https://docs.cloud.google.com/compute/docs/machine-types) `n1-standard-8`.
- Using an NVIDIA Tesla V100 [GPU](https://docs.cloud.google.com/compute/docs/gpus): `type=nvidia-tesla-v100,count=8`.
- With a boot disk of 120 GB.
- With an NVIDIA GPU driver set to install on first run: `install-nvidia-driver=True`.

> [!NOTE]
> **Note:** For more information about additional VM options available to you, see [Choosing an Image](https://docs.cloud.google.com/deep-learning-vm/docs/images).

At the command line, enter the following:

    export IMAGE_FAMILY="tf-latest-cu92"
    export ZONE="us-west1-b"
    export INSTANCE_NAME="my-new-instance"
    export INSTANCE_TYPE="n1-standard-8"
    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=8" \
            --machine-type=$INSTANCE_TYPE \
            --boot-disk-size=120GB \
            --metadata="install-nvidia-driver=True"

After some time, the VM instance is created and a summary of its configuration
is shown.

You've just created your first Deep Learning VM instance. To
verify the instance and see its status, use the `gcloud`
[`list`](https://docs.cloud.google.com/sdk/gcloud/reference/compute/instances/list) command as shown here
to list all instances:

    gcloud compute instances list

This displays all Compute Engine instances from all zones in the current project.

You can also view and maintain your Deep Learning VM instance on the
Google Cloud console in [Compute Engine VM
instances](https://console.cloud.google.com/compute/instances).

To view the status of just this instance:

    gcloud compute instances describe $INSTANCE_NAME

## Access your new instance

After you've created your Deep Learning VM instance, it starts
automatically. You can access it using SSH using the following command:

    gcloud compute ssh $INSTANCE_NAME

Compute Engine will propagate your SSH keys and create your user. For more
information, see [Connecting to
Instances](https://docs.cloud.google.com/compute/docs/instances/connecting-to-instance).

## Stop the instance

Run the following command from your local machine (not on the instance):

    gcloud compute instances stop $INSTANCE_NAME

The [`stop`](https://docs.cloud.google.com/sdk/gcloud/reference/compute/instances/stop) command performs a
clean shutdown.

## Start the instance

After the instance is initially created, Compute Engine starts it. To start the
instance manually when it's stopped, run the following command:

    gcloud compute instances start $INSTANCE_NAME

The [`start`](https://docs.cloud.google.com/sdk/gcloud/reference/compute/instances/start) command starts a
stopped virtual machine instance.

## Clean up


To avoid incurring charges to your Google Cloud account for
the resources used on this page, follow these steps.

To delete the Deep Learning VM instance that you created, at the
command line, enter the following command:

    gcloud compute instances delete $INSTANCE_NAME

The [`delete`](https://docs.cloud.google.com/sdk/gcloud/reference/compute/instances/delete) command deletes
Compute Engine instances.

## What's next

- Read a more in-depth description of this process in [Creating a
  Deep Learning VM instance From the
  CLI](https://docs.cloud.google.com/deep-learning-vm/docs/cli).
- Learn more about [Images, image families, and
  instances](https://docs.cloud.google.com/deep-learning-vm/docs/concepts-images).