This page shows you how to create a PyTorch Deep Learning VM Images instance with PyTorch and other tools pre-installed. You can create a PyTorch instance from Cloud Marketplace within the Google Cloud Console or using the command line.
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 Cloud project. Learn how to confirm that billing is enabled for your project.
- If you are using GPUs with your Deep Learning VM, check the quotas page 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.
Creating a PyTorch Deep Learning VM instance from the Cloud Marketplace
To create a PyTorch Deep Learning VM instance from the Cloud Marketplace, complete the following steps:
Go to the Deep Learning VM Cloud Marketplace page in the Cloud Console.
Enter a Deployment name, which will be the root of your VM name. Compute Engine appends
-vmto this name when naming your instance.
Select a Zone.
Under Machine type, select the specifications that you want for your VM. Learn more about machine types.
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.
Under Framework, select PyTorch 1.8 + fast.ai 2.1 (CUDA 11.0).
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.
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.
Select a boot disk type and boot disk size.
Select the networking settings that you want.
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 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:
- Download and install the Cloud SDK using the instructions given on Installing Google Cloud SDK.
- Initialize the SDK using the instructions given on Initializing Cloud SDK.
gcloud in Cloud Shell, first activate Cloud Shell using the
instructions given on Starting Cloud Shell.
To create a Deep Learning VM instance with the latest PyTorch image family and a CPU, enter the following at the command line:
export IMAGE_FAMILY="pytorch-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
--image-familymust be either
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 instance with the latest PyTorch image family and one or more attached GPUs, enter the following at the command line:
export IMAGE_FAMILY="pytorch-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"
--image-familymust be either
TERMINATE. To learn more, see GPU Restrictions.
--acceleratorspecifies the GPU type to use. Must be specified in the format
--accelerator="type=TYPE,count=COUNT". Supported values of
Not all GPU types are supported in all regions. For details, see GPUs on Compute Engine.
--metadatais 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
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 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.
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 createcommand, append the following:
For instructions on connecting to your new Deep Learning VM instance
through the Cloud Console or command line, see Connecting to
Instances. Your instance name
is the Deployment name you specified with