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
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
To use the Google Cloud CLI for this quickstart, you must first install and initialize the Google Cloud CLI:
- Download and install the Google Cloud CLI using the instructions given on Installing Google Cloud CLI.
- Initialize the SDK using the instructions given on Initializing Cloud SDK.
To use gcloud
in Cloud Shell for this quickstart, first activate
Cloud Shell using the instructions given on 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:
tf-latest-cu92
. - In the US West1-B zone:
us-west1-b
. - Named
my-new-instance
. - Of the instance type
n1-standard-8
. - Using an NVIDIA Tesla V100 GPU:
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
.
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
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.
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.
Stop the instance
Run the following command from your local machine (not on the instance):
gcloud compute instances stop $INSTANCE_NAME
The 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
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
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.
- Learn more about Images, image families, and instances.