A Vertex AI TensorBoard instance, which is a regionalized resource storing your Vertex AI TensorBoard experiments, must be present before the experiments can be visualized. You can create multiple instances in a project (for example, manually created or default created in the experiment SDK).
Create a Vertex AI TensorBoard instance
Vertex AI SDK for Python
Create Vertex AI TensorBoard instance using the Vertex AI SDK for Python.
Vertex AI SDK for Python
project
: Your project ID. You can find these IDs in the Google Cloud console welcome page.
display_name
: Provide a name for your TensorBoard instance.location
: See List of available locations Be sure to use a region that supports TensorBoard if creating a TensorBoard instance.
Google Cloud console
Follow these steps to create a Vertex AI TensorBoard instance using the Google Cloud console.
- If you're new to Vertex AI or starting a new project, set up your project and development environment.
- In the Vertex AI section of the Google Cloud console, go to the Experiments page.
Go to the Experiments page. - Navigate to the TensorBoard Instances tab.
- Click Create at the top of the page.
- Select a region from the Region drop-down list.
- Add a description. (optional)
- Click Create to create your TensorBoard instance
gcloud CLI
Use Google Cloud CLI to create a Vertex AI TensorBoard instance.- Install the gcloud CLI
- Initialize the Google Cloud CLI by running
gcloud init
. - To confirm installation, explore the commands.
gcloud ai tensorboards --help
The commands includecreate
,describe
,list
, anddelete
. If needed, you can follow these steps to set default values for your project and region before proceeding.
Now, you can create a Vertex AI TensorBoard instance. - Authenticate to the gcloud CLI.
gcloud auth application-default login
- Create a Vertex AI TensorBoard instance by providing a project name
and a display name. This step might take a few minutes to complete for the first
time in a project. Make note of the Vertex AI TensorBoard instance
name (for example:
projects/123/locations/us-central1/tensorboards/456
) that is printed at the end of the following command. You will need it in the later steps.
gcloud ai tensorboards create --display-name DISPLAY_NAME \ --project PROJECT_NAME
Replace the following:
PROJECT_NAME
: the project that you want to create the TensorBoard instance inDISPLAY_NAME
: a descriptive name for the TensorBoard instance
TensorBoard logs
Vertex AI TensorBoard offers Google Cloud CLI and Vertex AI SDK for Python for uploading TensorBoard logs. You can upload logs from any environment which can connect to Google Cloud.
Create a virtual environment (optional)
Optional, but recommended first step:
- Create a dedicated virtual environment to install the Vertex AI TensorBoard Uploader Python CLI.
python3 -m venv PATH/TO/VIRTUAL/ENVIRONMENT
source PATH/TO/VIRTUAL/ENVIRONMENT/bin/activate
- Replace
PATH/TO/VIRTUAL/ENVIRONMENT
with the path to your dedicated virtual environment.
Install the Vertex AI TensorBoard package through Vertex AI SDK
The uploader needs the latest version of pip in order to be installed properly.
pip install -U pip
pip install google-cloud-aiplatform[tensorboard]
Upload Vertex AI TensorBoard logs
Vertex AI SDK for Python
Continuous monitoring
Call aiplatform.start_upload_tb_log
at the beginning of the training.
The SDK opens a new thread for uploading. This thread keeps monitoring when there's
new data in the directory.
When training completes, call end_upload_tb_log
which kills the uploader thread.
If end_upload_tb_log
isn't called, a time out plan closes the
thread.
Vertex AI SDK for Python
tensorboard_experiment_name
: Name of this experiment.logdir
: The location of the TensorBoard logs that reside either in your local file system or Cloud Storage.tensorboard_id
:- To find the
tensorboard_id
, go to the Experiments page Vertex AI section of the Google Cloud console, and then select the TensorBoard Instances tab.
Go to the Experiments page
tensorboard_id
inaiplatform.init
is used.- To find the
project
: Your project ID. You can find these Project IDs in the Google Cloud console welcome page.location
: See List of available locationsexperiment_display_name
: The display name of the experiment.run_name_prefix
: If present, all runs created by this invocation will have their name prefixed by this value.description
: A string description to assign to the experiment.
One time logging
Calling aiplatform.upload_tb_log
to perform a one-time uploading of TensorBoard logs.
It uploads only the existing data in the logdir and then returns immediately.
Vertex AI SDK for Python
tensorboard_experiment_name
: This is the name of this tensorboard experiment.projects/{project}/locations/{location}/tensorboards/{tensorboard_id}
logdir
: The location of the TensorBoard logs that reside either in your local file system or Cloud Storage.tensorboard_id
:- To find the
tensorboard_id
, go to the Experiments page Vertex AI section of the Google Cloud console, and then select the TensorBoard Instances tab.
Go to the Experiments page
tensorboard_id
inaiplatform.init
is used.- To find the
project
: Your project ID. You can find these Project IDs in the Google Cloud console welcome page.location
: See List of available locationsexperiment_display_name
: The display name of the experiment.run_name_prefix
: If present, all runs created by this invocation will have their name prefixed by this value.description
: A string description to assign to the experiment.verbosity
: Level of statistics verbosity, an integer. Supported value: 0 - No upload statistics are printed. 1 - Print upload statistics while uploading data (default).
gcloud CLI
tb-gcp-uploader --tensorboard_resource_name \
TENSORBOARD_INSTANCE_NAME \
--logdir=LOG_DIR \
--experiment_name=TB_EXPERIMENT_NAME --one_shot=True
- TENSORBOARD_INSTANCE_NAME: there are two ways to
identify the instance name:
- The full name is printed at the end of the
gcloud ai tensorboards create
command that you used previously. - If the TensorBoard Instance was created using the
Google Cloud console, the
TENSORBOARD_INSTANCE_NAME is
projects/PROJECT_ID_OR_NUMBER/locations/REGION/tensorboards/TENSORBOARD_INSTANCE_ID
- To find the
TENSORBOARD_INSTANCE_ID
, go to the Experiments page Vertex AI section of the Google Cloud console, and then select the TensorBoard Instances tab.
Go to the Experiments page
- The full name is printed at the end of the
LOG_DIR
: the location of the event logs that resides either in the local file system or Cloud StorageTB_EXPERIMENT_NAME
: the name of the experiment, for exampletest-experiment
. The experiment name should be unique within a TensorBoard resource
The uploader CLI by default runs indefinitely, monitoring changes in the LOG_DIR,
and uploads newly added logs. --one_shot=True
disables the
behavior. Run tb-gcp-uploader --help
for more information.
View a Vertex AI TensorBoard experiment
You can access your Vertex AI TensorBoard experiment from the Google Cloud console or, when using the Vertex AI TensorBoard package, the Google Cloud CLI outputs a link to the Vertex AI TensorBoard instance.
Access the Vertex AI TensorBoard using the Google Cloud console
You can access your Vertex AI TensorBoard experiment from the Google Cloud console with the following steps.
In the Vertex AI section of the Google Cloud console, go to the Experiments page.
From the experiments tab, scroll or filter the experiments list to find your experiment.
To open the Vertex AI TensorBoard web application page, click Open TensorBoard next to your experiment.
Vertex AI TensorBoard web application view appears.
You can share the link to this view with others who have
permission.
If you use Vertex AI TensorBoard with custom training, select the experiment from the Experiments Tracking page. An Open TensorBoard button appears at the top of the page. Similarly, if you use Vertex AI TensorBoard in a Vertex AI Pipelines, an Open TensorBoard button appears when you select the associated component.
Use the link from Google Cloud CLI output
In addition, when using the Vertex AI TensorBoard package, the
Google Cloud CLI outputs
a link to the Vertex AI TensorBoard instance in the
first few lines of the log where you can view your experiment. For example:
View your TensorBoard at
https://us-central1.tensorboard.googleusercontent.com/experiment/projects+123+locations+us-central1+tensorboards+4567+experiments+my-experiment-name
Notebooks
What's next
Check out the TensorBoard API documentation.