This page describes the two different ways to create a notebook instance, and how to register a legacy AI Platform Notebooks instance with the AI Platform Notebooks API. If you created notebook instances before the AI Platform Notebooks API was Generally Available, or continued to create notebooks using the Compute Engine API after general availability, you must register those instances with the AI Platform Notebooks API to use new functionality and features added with the AI Platform Notebooks API.
Two ways to create a notebook instance
There are two different ways to create an AI Platform Notebooks instance:
Use the AI Platform Notebooks API. This method gives you the most up to date features and functionality.
Use the Compute Engine API. AI Platform Notebooks instances created using this method are called legacy instances and do not have the latest updates to features and functionality.
Registering a legacy notebook instance with the AI Platform Notebooks API
You must register legacy instances to be able to manage them using the AI Platform Notebooks API.
Before you attempt to register your legacy instances, review the Requirements and limitations.
To register your legacy instance with the AI Platform Notebooks API, you can
use the Register all option in the Google Cloud Console, or use the
register
method provided by the AI Platform Notebooks API.
Using the console
To use the Register all option in the Cloud Console, complete the following steps.
Before you attempt to migrate your instance, review the requirements and limitations.
Go to the AI Platform Notebooks page in the Cloud Console.
If you have one or more legacy notebook instances, a message appears indicating that you need to register them with the AI Platform Notebooks API. Next to this message, click Register all.
If you do not have any legacy notebook instances, but have not yet enabled the AI Platform Notebooks API, click Enable Notebooks API to ensure that new notebook instances can be created using the AI Platform Notebooks API.
Using the API
To use the
register
method provided by the AI Platform Notebooks API,
complete the following steps.
Before you attempt to migrate your instance, review the requirements and limitations.
Type the following command in either Cloud Shell or any environment where the Cloud SDK is installed. Replace my-instance-name and my-zone with the relevant information.
gcloud notebooks instances register my-instance-name --location=my-zone
Requirements and limitations
Consider the following requirements and limitations before registering your legacy instances with the AI Platform Notebooks API.
The source and destination zones must match and be a valid zone for AI Platform Notebooks API. For example, a legacy notebook instance in
us-west1-a
remains inus-west1-a
when it is registered with the AI Platform Notebooks API. However, a legacy notebook instance inus-central1-f
will fail to register with the AI Platform Notebooks API becauseus-central1-f
is not a supported zone for the AI Platform Notebooks API.To get a list of the valid zones for AI Platform Notebooks API notebooks instances, type the following command in either Cloud Shell or any environment where the Cloud SDK is installed.
gcloud notebooks locations list
If your legacy instance's zone is not supported by AI Platform Notebooks API, contact support or your account manager. Or you can migrate the legacy instance to a new AI Platform Notebooks instance.
Single-disk legacy instances cannot use some AI Platform Notebooks features, such as auto upgrade, even after they are registered with the AI Platform Notebooks API. To enable your instance to use all available features, you must migrate your single-disk instance to a dual-disk instance. You can do this as part of your migration from legacy instance to an instance registered with the AI Platform Notebooks API. If you've already registered the legacy instance with the AI Platform Notebooks API, you can still migrate the instance to a new dual-disk instance to resolve the issue.
To verify the number of disks, complete the following steps.
Using the console
Go to the Compute Engine page in the Cloud Console.
Find your current legacy AI Platform Notebooks instance.
Click the instance name to open the VM instance details page.
In the boot disk and additional disks sections, verify how many disks are attached to the VM.
Using the CLI
Type the following command in either Cloud Shell or any environment where the Cloud SDK is installed.
Replace my-instance-name and my-zone with the relevant information.
gcloud compute instances describe my-instance-name --zone=my-zone
Review the information that follows disks:, and verify how many disks are attached to the VM.
Migrating a notebook instance to a new AI Platform Notebooks instance
If your legacy AI Platform Notebooks instance is not migratable because it's located in a zone that the AI Platform Notebooks API doesn't support, or if you want to migrate from a single-disk instance to a dual-disk instance, you must create a new AI Platform Notebooks instance and copy your legacy instance's user data to the new instance. To do so, complete the following steps:
Use ssh to connect to your legacy instance by typing the following command in either Cloud Shell or any environment where the Cloud SDK is installed. Replace my-project-id, my-zone, and my-instance with the relevant information.
export PROJECT_ID="my-project-id" export ZONE="my-zone" export INSTANCE_NAME="my-instance" gcloud compute ssh --project $PROJECT_ID --zone $ZONE $INSTANCE_NAME -- -L 8080:localhost:8080
Copy the contents of the legacy instance to a Cloud Storage bucket using
gsutil
. The following example command copies all of the notebook (.ipynb) files from the default directory/home/jupyter/
to a Cloud Storage directory namedmy-bucket/legacy-notebooks
.gsutil cp -R /home/jupyter/*.ipynb gs://my-bucket/legacy-notebooks/
Create a new AI Platform Notebooks instance with the same hardware specifications as the legacy instance. You can create the instance using the Cloud Console or use the following example command in either Cloud Shell or any environment where the Cloud SDK is installed. In this example, AI Platform Notebooks creates a new instance named
new-notebook
in theexample
project using the latest TensorFlow 2 image, with ann1-standard-1
machine type, in theus-west1-a
zone.gcloud notebooks instances create new-notebook \ --vm-image-project=example \ --vm-image-family=tf2-latest-cpu \ --machine-type=n1-standard-1 \ --location=us-west1-a
The new AI Platform Notebooks instance is dual-disk. It has a boot disk and a data disk.
Use ssh to connect to the AI Platform Notebooks instance that you just created.
Copy the contents of the legacy instance from the Cloud Storage bucket to the new instance using
gsutil
. The following example command copies all of the notebook (.ipynb) files from the Cloud Storage directory to the new instance's/home/jupyter/
directory.gsutil cp -R gs://my-bucket/legacy-notebooks/*.ipynb /home/jupyter/
In the new AI Platform Notebooks instance, open JupyterLab and confirm that the user data and assets have been successfully copied.
Optionally, delete the legacy instance.
What's next
Go to the AI Platform Notebooks page in the Cloud Console to register legacy instances and enable the AI Platform Notebooks API.
Go to the AI Platform Notebooks page