Updated on 2024-10-29 GMT+08:00

Using TensorBoard Visualization Jobs in JupyterLab

ModelArts supports TensorBoard for visualizing training jobs. TensorBoard is a visualization tool package of TensorFlow. It provides visualization functions and tools required for machine learning experiments.

TensorBoard effectively displays the computational graph of TensorFlow in the running process, the trend of all metrics in time, and the data used in the training. For more details about TensorBoard, see TensorBoard official website.

TensorBoard visualization training jobs support only CPU and GPU flavors based on TensorFlow and PyTorch images. Select images and flavors based on the site requirements.

Prerequisites

When you write a training script, add the code for collecting the summary record to the script to ensure that the summary file is generated in the training result.

For details about how to add the code for collecting the summary record to a TensorFlow-powered training script, see TensorFlow official website.

Precautions

  • A running visualization job is not billed separately. When the target notebook instance is stopped, the billing stops.
  • If the summary file is stored in OBS, you will be charged for the storage. After a job is complete, stop the notebook instance and clear OBS data to stop billing.

Step 1 Create a Development Environment and Access It Online

Log in to the ModelArts management console. In the navigation pane on the left, choose Development Workspace > Notebook. Create an instance using a TensorFlow or PyTorch image. After the instance is created, click Open in the Operation column of the instance to access it online.

TensorBoard visualization training jobs support only CPU and GPU flavors based on TensorFlow and PyTorch images. Select images and flavors based on the site requirements.

Step 2 Upload the Summary Data

Summary data is required for using TensorBoard visualization functions in DevEnviron.

You can upload the summary data to the /home/ma-user/work/ directory in the development environment or store it in the OBS parallel file system.

  • For details about how to upload the summary data to the notebook path /home/ma-user/work/, see Uploading Files from a Local Path to JupyterLab.
  • To store the summary data in an OBS parallel file system that is mounted to a notebook instance, upload the summary file generated during model training to the OBS parallel file system and ensure that the OBS parallel file system and ModelArts are in the same region. When TensorBoard is started in a notebook instance, the notebook instance automatically mounts the OBS parallel file system directory and reads the summary data.

Step 3 Start TensorBoard

Choose a way you like to start TensorBoard in JupyterLab.

Figure 1 Starting TensorBoard in JupyterLab
  1. Open JupyterLab, in the navigation pane on the left, create the summary folder, and upload data to /home/ma-user/work/summary. The folder name must be summary.
  2. Go to the summary folder and click to go to the TensorBoard page. See Figure 2.
    Figure 2 TensorBoard page (1)

Step 4 View Visualized Data on the Training Dashboard

For TensorBoard visualization, you need the training dashboard. It lets you visualize scalars, images, and computational graphs.

For more functions, see Get started with TensorBoard.

Disabling TensorBoard

To stop a TensorBoard instance, use any of the following methods:

Click . The TensorBoard instance management page is displayed, which shows all started TensorBoard instances. Click SHUT DOWN next to an instance.
Figure 3 Clicking SHUT DOWN to stop an instance