Đào tạo và phục vụ Vertex AI với các đường ống TFX và Vertex

Hướng dẫn dựa trên sổ tay này sẽ tạo và chạy đường ống TFX đào tạo mô hình ML bằng dịch vụ Vertex AI Training và xuất bản nó lên Vertex AI để phục vụ.

Máy tính xách tay này được dựa trên các đường ống dẫn TFX chúng tôi xây dựng trong đơn giản TFX đường ống cho Vertex Đường ống Tutorial . Nếu bạn chưa đọc hướng dẫn đó, bạn nên đọc nó trước khi tiếp tục với sổ tay này.

Bạn có thể đào tạo các mô hình trên Vertex AI bằng AutoML hoặc sử dụng đào tạo tùy chỉnh. Trong đào tạo tùy chỉnh, bạn có thể chọn nhiều loại máy khác nhau để cung cấp năng lượng cho công việc đào tạo của mình, cho phép đào tạo phân tán, sử dụng điều chỉnh siêu tham số và tăng tốc với GPU.

Bạn cũng có thể phục vụ các yêu cầu dự đoán bằng cách triển khai mô hình được đào tạo tới Mô hình Vertex AI và tạo một điểm cuối.

Trong hướng dẫn này, chúng tôi sẽ sử dụng Vertex AI Training với các công việc tùy chỉnh để đào tạo một mô hình trong đường ống TFX. Chúng tôi cũng sẽ triển khai mô hình để phục vụ yêu cầu dự đoán bằng Vertex AI.

Máy tính xách tay này được thiết kế để chạy trên Google Colab hoặc trên AI vBulletin Máy tính xách tay . Nếu bạn không sử dụng một trong những cách này, bạn có thể chỉ cần nhấp vào nút "Chạy trong Google Colab" ở trên.

Cài đặt

Nếu bạn đã hoàn thành đơn giản TFX đường ống cho Vertex Đường ống Tutorial , bạn sẽ có một dự án GCP làm việc và một cái xô GCS và đó là tất cả chúng ta cần cho hướng dẫn này. Vui lòng đọc hướng dẫn sơ bộ trước nếu bạn bỏ lỡ nó.

Cài đặt gói python

Chúng tôi sẽ cài đặt các gói Python được yêu cầu bao gồm TFX và KFP để tác giả các đường ống ML và gửi công việc cho Vertex Pipelines.

# Use the latest version of pip.
pip install --upgrade pip
pip install --upgrade "tfx[kfp]<2"

Bạn có khởi động lại thời gian chạy không?

Nếu bạn đang sử dụng Google Colab, lần đầu tiên bạn chạy ô ở trên, bạn phải khởi động lại thời gian chạy bằng cách nhấp vào phía trên nút "RESTART RUNTIME" hoặc sử dụng menu "Runtime> Restart runtime ...". Điều này là do cách Colab tải các gói.

Nếu bạn không ở trên Colab, bạn có thể khởi động lại thời gian chạy bằng ô sau.

# docs_infra: no_execute
import sys
if not 'google.colab' in sys.modules:
  # Automatically restart kernel after installs
  import IPython
  app = IPython.Application.instance()
  app.kernel.do_shutdown(True)

Đăng nhập vào Google cho sổ tay này

Nếu bạn đang chạy sổ ghi chép này trên Colab, hãy xác thực bằng tài khoản người dùng của bạn:

import sys
if 'google.colab' in sys.modules:
  from google.colab import auth
  auth.authenticate_user()

Nếu bạn đang ở trên AI vBulletin Máy tính xách tay, xác thực với Google Cloud trước khi chạy phần tiếp theo, bằng cách chạy

gcloud auth login

trong cửa sổ Terminal (mà bạn có thể mở thông qua File> New trong menu). Bạn chỉ cần làm điều này một lần cho mỗi phiên bản sổ ghi chép.

Kiểm tra các phiên bản gói.

import tensorflow as tf
print('TensorFlow version: {}'.format(tf.__version__))
from tfx import v1 as tfx
print('TFX version: {}'.format(tfx.__version__))
import kfp
print('KFP version: {}'.format(kfp.__version__))
TensorFlow version: 2.6.2
TFX version: 1.4.0
KFP version: 1.8.1

Thiết lập các biến

Chúng tôi sẽ thiết lập một số biến được sử dụng để tùy chỉnh các đường ống bên dưới. Thông tin sau là bắt buộc:

Nhập các giá trị cần thiết trong các tế bào dưới đây trước khi chạy nó.

GOOGLE_CLOUD_PROJECT = ''     # <--- ENTER THIS
GOOGLE_CLOUD_REGION = ''      # <--- ENTER THIS
GCS_BUCKET_NAME = ''          # <--- ENTER THIS

if not (GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_REGION and GCS_BUCKET_NAME):
    from absl import logging
    logging.error('Please set all required parameters.')
ERROR:absl:Please set all required parameters.

Set gcloud sử dụng dự án của bạn.

gcloud config set project {GOOGLE_CLOUD_PROJECT}
ERROR: (gcloud.config.set) argument VALUE: Must be specified.
Usage: gcloud config set SECTION/PROPERTY VALUE [optional flags]
  optional flags may be  --help | --installation

For detailed information on this command and its flags, run:
  gcloud config set --help
PIPELINE_NAME = 'penguin-vertex-training'

# Path to various pipeline artifact.
PIPELINE_ROOT = 'gs://{}/pipeline_root/{}'.format(GCS_BUCKET_NAME, PIPELINE_NAME)

# Paths for users' Python module.
MODULE_ROOT = 'gs://{}/pipeline_module/{}'.format(GCS_BUCKET_NAME, PIPELINE_NAME)

# Paths for users' data.
DATA_ROOT = 'gs://{}/data/{}'.format(GCS_BUCKET_NAME, PIPELINE_NAME)

# Name of Vertex AI Endpoint.
ENDPOINT_NAME = 'prediction-' + PIPELINE_NAME

print('PIPELINE_ROOT: {}'.format(PIPELINE_ROOT))
PIPELINE_ROOT: gs:///pipeline_root/penguin-vertex-training

Chuẩn bị dữ liệu mẫu

Chúng tôi sẽ sử dụng cùng một Palmer Penguins bộ dữ liệu như đơn giản TFX Pipeline Tutorial .

Có bốn tính năng số trong tập dữ liệu này đã được chuẩn hóa để có phạm vi [0,1]. Chúng tôi sẽ xây dựng một mô hình phân loại dự đoán các species chim cánh cụt.

Chúng tôi cần tạo bản sao tập dữ liệu của riêng mình. Vì TFX ExampleGen đọc đầu vào từ một thư mục, chúng ta cần tạo một thư mục và sao chép tập dữ liệu vào nó trên GCS.

gsutil cp gs://download.tensorflow.org/data/palmer_penguins/penguins_processed.csv {DATA_ROOT}/
InvalidUrlError: Cloud URL scheme should be followed by colon and two slashes: "://". Found: "gs:///data/penguin-vertex-training/".

Hãy xem nhanh tệp CSV.

gsutil cat {DATA_ROOT}/penguins_processed.csv | head
InvalidUrlError: Cloud URL scheme should be followed by colon and two slashes: "://". Found: "gs:///data/penguin-vertex-training/penguins_processed.csv".

Tạo một đường dẫn

Đường ống của chúng tôi sẽ rất giống với các đường ống dẫn chúng ta tạo ra trong Simple TFX đường ống cho Vertex Đường ống Tutorial . Đường ống sẽ bao gồm ba thành phần, CsvExampleGen, Trainer và Pusher. Nhưng chúng tôi sẽ sử dụng một thành phần Trainer và Pusher đặc biệt. Thành phần Trainer sẽ chuyển khối lượng công việc đào tạo sang Vertex AI và thành phần Pusher sẽ xuất bản mô hình ML được đào tạo lên Vertex AI thay vì một hệ thống tệp.

TFX cung cấp một đặc biệt Trainer trình đào tạo nghề để phục vụ Vertex AI Đào tạo. Tất cả chúng ta phải làm là sử dụng Trainer trong các mô-đun mở rộng thay vì tiêu chuẩn Trainer thành phần cùng với một số thông số GCP yêu cầu.

Trong hướng dẫn này, chúng tôi sẽ chạy các công việc Vertex AI Training chỉ sử dụng CPU trước và sau đó là GPU.

TFX cũng cung cấp một đặc biệt Pusher để tải lên các mô hình để Vertex AI Models. Pusher sẽ tạo ra nguồn Vertex AI Endpoint để phục vụ perdictions trực tuyến, quá. Xem tài liệu Vertex AI để tìm hiểu thêm về những dự đoán trực tuyến được cung cấp bởi Vertex AI.

Viết mã mô hình.

Mô hình chính nó là gần như tương tự như mô hình trong Simple TFX Pipeline Tutorial .

Chúng tôi sẽ bổ sung thêm _get_distribution_strategy() chức năng mà tạo ra một chiến lược phân phối TensorFlow và nó được sử dụng trong run_fn sử dụng MirroredStrategy nếu GPU có sẵn.

_trainer_module_file = 'penguin_trainer.py'
%%writefile {_trainer_module_file}

# Copied from https://www.tensorflow.org/tfx/tutorials/tfx/penguin_simple and
# slightly modified run_fn() to add distribution_strategy.

from typing import List
from absl import logging
import tensorflow as tf
from tensorflow import keras
from tensorflow_metadata.proto.v0 import schema_pb2
from tensorflow_transform.tf_metadata import schema_utils

from tfx import v1 as tfx
from tfx_bsl.public import tfxio

_FEATURE_KEYS = [
    'culmen_length_mm', 'culmen_depth_mm', 'flipper_length_mm', 'body_mass_g'
]
_LABEL_KEY = 'species'

_TRAIN_BATCH_SIZE = 20
_EVAL_BATCH_SIZE = 10

# Since we're not generating or creating a schema, we will instead create
# a feature spec.  Since there are a fairly small number of features this is
# manageable for this dataset.
_FEATURE_SPEC = {
    **{
        feature: tf.io.FixedLenFeature(shape=[1], dtype=tf.float32)
        for feature in _FEATURE_KEYS
    }, _LABEL_KEY: tf.io.FixedLenFeature(shape=[1], dtype=tf.int64)
}


def _input_fn(file_pattern: List[str],
              data_accessor: tfx.components.DataAccessor,
              schema: schema_pb2.Schema,
              batch_size: int) -> tf.data.Dataset:
  """Generates features and label for training.

  Args:
    file_pattern: List of paths or patterns of input tfrecord files.
    data_accessor: DataAccessor for converting input to RecordBatch.
    schema: schema of the input data.
    batch_size: representing the number of consecutive elements of returned
      dataset to combine in a single batch

  Returns:
    A dataset that contains (features, indices) tuple where features is a
      dictionary of Tensors, and indices is a single Tensor of label indices.
  """
  return data_accessor.tf_dataset_factory(
      file_pattern,
      tfxio.TensorFlowDatasetOptions(
          batch_size=batch_size, label_key=_LABEL_KEY),
      schema=schema).repeat()


def _make_keras_model() -> tf.keras.Model:
  """Creates a DNN Keras model for classifying penguin data.

  Returns:
    A Keras Model.
  """
  # The model below is built with Functional API, please refer to
  # https://www.tensorflow.org/guide/keras/overview for all API options.
  inputs = [keras.layers.Input(shape=(1,), name=f) for f in _FEATURE_KEYS]
  d = keras.layers.concatenate(inputs)
  for _ in range(2):
    d = keras.layers.Dense(8, activation='relu')(d)
  outputs = keras.layers.Dense(3)(d)

  model = keras.Model(inputs=inputs, outputs=outputs)
  model.compile(
      optimizer=keras.optimizers.Adam(1e-2),
      loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
      metrics=[keras.metrics.SparseCategoricalAccuracy()])

  model.summary(print_fn=logging.info)
  return model


# NEW: Read `use_gpu` from the custom_config of the Trainer.
#      if it uses GPU, enable MirroredStrategy.
def _get_distribution_strategy(fn_args: tfx.components.FnArgs):
  if fn_args.custom_config.get('use_gpu', False):
    logging.info('Using MirroredStrategy with one GPU.')
    return tf.distribute.MirroredStrategy(devices=['device:GPU:0'])
  return None


# TFX Trainer will call this function.
def run_fn(fn_args: tfx.components.FnArgs):
  """Train the model based on given args.

  Args:
    fn_args: Holds args used to train the model as name/value pairs.
  """

  # This schema is usually either an output of SchemaGen or a manually-curated
  # version provided by pipeline author. A schema can also derived from TFT
  # graph if a Transform component is used. In the case when either is missing,
  # `schema_from_feature_spec` could be used to generate schema from very simple
  # feature_spec, but the schema returned would be very primitive.
  schema = schema_utils.schema_from_feature_spec(_FEATURE_SPEC)

  train_dataset = _input_fn(
      fn_args.train_files,
      fn_args.data_accessor,
      schema,
      batch_size=_TRAIN_BATCH_SIZE)
  eval_dataset = _input_fn(
      fn_args.eval_files,
      fn_args.data_accessor,
      schema,
      batch_size=_EVAL_BATCH_SIZE)

  # NEW: If we have a distribution strategy, build a model in a strategy scope.
  strategy = _get_distribution_strategy(fn_args)
  if strategy is None:
    model = _make_keras_model()
  else:
    with strategy.scope():
      model = _make_keras_model()

  model.fit(
      train_dataset,
      steps_per_epoch=fn_args.train_steps,
      validation_data=eval_dataset,
      validation_steps=fn_args.eval_steps)

  # The result of the training should be saved in `fn_args.serving_model_dir`
  # directory.
  model.save(fn_args.serving_model_dir, save_format='tf')
Writing penguin_trainer.py

Sao chép tệp mô-đun sang GCS có thể được truy cập từ các thành phần đường ống.

Nếu không, bạn có thể muốn xây dựng hình ảnh vùng chứa bao gồm tệp mô-đun và sử dụng hình ảnh để chạy các công việc đào tạo nền tảng và nền tảng AI.

gsutil cp {_trainer_module_file} {MODULE_ROOT}/
InvalidUrlError: Cloud URL scheme should be followed by colon and two slashes: "://". Found: "gs:///pipeline_module/penguin-vertex-training/".

Viết định nghĩa đường ống

Chúng tôi sẽ xác định một chức năng để tạo một đường ống TFX. Nó có cùng ba thành phần như trong đơn giản TFX Pipeline Hướng dẫn , nhưng chúng tôi sử dụng một TrainerPusher thành phần trong các mô-đun mở rộng GCP.

tfx.extensions.google_cloud_ai_platform.Trainer cư xử giống như một thường xuyên Trainer , nhưng nó chỉ di chuyển các tính toán cho việc đào tạo mô hình để đám mây. Nó khởi chạy một công việc tùy chỉnh trong dịch vụ Vertex AI Training và thành phần huấn luyện viên trong hệ thống điều phối sẽ chỉ đợi cho đến khi công việc Vertex AI Training hoàn thành.

tfx.extensions.google_cloud_ai_platform.Pusher tạo ra một Vertex AI Model và một Vertex AI Endpoint sử dụng mô hình đào tạo.

def _create_pipeline(pipeline_name: str, pipeline_root: str, data_root: str,
                     module_file: str, endpoint_name: str, project_id: str,
                     region: str, use_gpu: bool) -> tfx.dsl.Pipeline:
  """Implements the penguin pipeline with TFX."""
  # Brings data into the pipeline or otherwise joins/converts training data.
  example_gen = tfx.components.CsvExampleGen(input_base=data_root)

  # NEW: Configuration for Vertex AI Training.
  # This dictionary will be passed as `CustomJobSpec`.
  vertex_job_spec = {
      'project': project_id,
      'worker_pool_specs': [{
          'machine_spec': {
              'machine_type': 'n1-standard-4',
          },
          'replica_count': 1,
          'container_spec': {
              'image_uri': 'gcr.io/tfx-oss-public/tfx:{}'.format(tfx.__version__),
          },
      }],
  }
  if use_gpu:
    # See https://cloud.google.com/vertex-ai/docs/reference/rest/v1/MachineSpec#acceleratortype
    # for available machine types.
    vertex_job_spec['worker_pool_specs'][0]['machine_spec'].update({
        'accelerator_type': 'NVIDIA_TESLA_K80',
        'accelerator_count': 1
    })

  # Trains a model using Vertex AI Training.
  # NEW: We need to specify a Trainer for GCP with related configs.
  trainer = tfx.extensions.google_cloud_ai_platform.Trainer(
      module_file=module_file,
      examples=example_gen.outputs['examples'],
      train_args=tfx.proto.TrainArgs(num_steps=100),
      eval_args=tfx.proto.EvalArgs(num_steps=5),
      custom_config={
          tfx.extensions.google_cloud_ai_platform.ENABLE_UCAIP_KEY:
              True,
          tfx.extensions.google_cloud_ai_platform.UCAIP_REGION_KEY:
              region,
          tfx.extensions.google_cloud_ai_platform.TRAINING_ARGS_KEY:
              vertex_job_spec,
          'use_gpu':
              use_gpu,
      })

  # NEW: Configuration for pusher.
  vertex_serving_spec = {
      'project_id': project_id,
      'endpoint_name': endpoint_name,
      # Remaining argument is passed to aiplatform.Model.deploy()
      # See https://cloud.google.com/vertex-ai/docs/predictions/deploy-model-api#deploy_the_model
      # for the detail.
      #
      # Machine type is the compute resource to serve prediction requests.
      # See https://cloud.google.com/vertex-ai/docs/predictions/configure-compute#machine-types
      # for available machine types and acccerators.
      'machine_type': 'n1-standard-4',
  }

  # Vertex AI provides pre-built containers with various configurations for
  # serving.
  # See https://cloud.google.com/vertex-ai/docs/predictions/pre-built-containers
  # for available container images.
  serving_image = 'us-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-6:latest'
  if use_gpu:
    vertex_serving_spec.update({
        'accelerator_type': 'NVIDIA_TESLA_K80',
        'accelerator_count': 1
    })
    serving_image = 'us-docker.pkg.dev/vertex-ai/prediction/tf2-gpu.2-6:latest'

  # NEW: Pushes the model to Vertex AI.
  pusher = tfx.extensions.google_cloud_ai_platform.Pusher(
      model=trainer.outputs['model'],
      custom_config={
          tfx.extensions.google_cloud_ai_platform.ENABLE_VERTEX_KEY:
              True,
          tfx.extensions.google_cloud_ai_platform.VERTEX_REGION_KEY:
              region,
          tfx.extensions.google_cloud_ai_platform.VERTEX_CONTAINER_IMAGE_URI_KEY:
              serving_image,
          tfx.extensions.google_cloud_ai_platform.SERVING_ARGS_KEY:
            vertex_serving_spec,
      })

  components = [
      example_gen,
      trainer,
      pusher,
  ]

  return tfx.dsl.Pipeline(
      pipeline_name=pipeline_name,
      pipeline_root=pipeline_root,
      components=components)

Chạy đường ống trên Vertex Pipelines.

Chúng tôi sẽ sử dụng Vertex Đường ống để chạy các đường ống như chúng ta đã làm trong đơn giản TFX đường ống cho Vertex Đường ống Tutorial .

import os

PIPELINE_DEFINITION_FILE = PIPELINE_NAME + '_pipeline.json'

runner = tfx.orchestration.experimental.KubeflowV2DagRunner(
    config=tfx.orchestration.experimental.KubeflowV2DagRunnerConfig(),
    output_filename=PIPELINE_DEFINITION_FILE)
_ = runner.run(
    _create_pipeline(
        pipeline_name=PIPELINE_NAME,
        pipeline_root=PIPELINE_ROOT,
        data_root=DATA_ROOT,
        module_file=os.path.join(MODULE_ROOT, _trainer_module_file),
        endpoint_name=ENDPOINT_NAME,
        project_id=GOOGLE_CLOUD_PROJECT,
        region=GOOGLE_CLOUD_REGION,
        # We will use CPUs only for now.
        use_gpu=False))

Các tập tin định nghĩa được tạo ra có thể được nộp bằng Google Cloud client aiplatform trong google-cloud-aiplatform gói.

# docs_infra: no_execute
from google.cloud import aiplatform
from google.cloud.aiplatform import pipeline_jobs

aiplatform.init(project=GOOGLE_CLOUD_PROJECT, location=GOOGLE_CLOUD_REGION)

job = pipeline_jobs.PipelineJob(template_path=PIPELINE_DEFINITION_FILE,
                                display_name=PIPELINE_NAME)
job.run(sync=False)

Bây giờ bạn có thể ghé thăm 'Vertex AI> Đường ống' trong Google Cloud Console để xem sự tiến bộ.

Kiểm tra với một yêu cầu dự đoán

Khi Hoàn thành đường ống dẫn, bạn sẽ tìm thấy một mô hình được triển khai tại một trong những thiết bị đầu cuối trong 'Vertex AI> Thiết bị đầu cuối. Chúng ta cần biết id của điểm cuối để gửi yêu cầu dự đoán đến điểm cuối mới. Điều này khác với tên thiết bị đầu cuối, chúng tôi đã nhập ở trên. Bạn có thể tìm id tại trang thiết bị đầu cuối trong Google Cloud Console , nó trông giống như một số rất dài.

Đặt ENDPOINT_ID bên dưới trước khi chạy nó.

ENDPOINT_ID=''     # <--- ENTER THIS
if not ENDPOINT_ID:
    from absl import logging
    logging.error('Please set the endpoint id.')
ERROR:absl:Please set the endpoint id.

Chúng tôi sử dụng cùng một ứng dụng khách aiplatform để gửi yêu cầu đến điểm cuối. Chúng tôi sẽ gửi yêu cầu dự đoán về phân loại loài Penguin. Đầu vào là bốn tính năng mà chúng tôi đã sử dụng và mô hình sẽ trả về ba giá trị, vì mô hình của chúng tôi xuất ra một giá trị cho mỗi loài.

Ví dụ, ví dụ cụ thể sau đây có giá trị lớn nhất tại chỉ mục '2' và sẽ in ra '2'.

# docs_infra: no_execute
import numpy as np

# The AI Platform services require regional API endpoints.
client_options = {
    'api_endpoint': GOOGLE_CLOUD_REGION + '-aiplatform.googleapis.com'
    }
# Initialize client that will be used to create and send requests.
client = aiplatform.gapic.PredictionServiceClient(client_options=client_options)

# Set data values for the prediction request.
# Our model expects 4 feature inputs and produces 3 output values for each
# species. Note that the output is logit value rather than probabilities.
# See the model code to understand input / output structure.
instances = [{
    'culmen_length_mm':[0.71],
    'culmen_depth_mm':[0.38],
    'flipper_length_mm':[0.98],
    'body_mass_g': [0.78],
}]

endpoint = client.endpoint_path(
    project=GOOGLE_CLOUD_PROJECT,
    location=GOOGLE_CLOUD_REGION,
    endpoint=ENDPOINT_ID,
)
# Send a prediction request and get response.
response = client.predict(endpoint=endpoint, instances=instances)

# Uses argmax to find the index of the maximum value.
print('species:', np.argmax(response.predictions[0]))

Để biết thông tin chi tiết về dự báo trực tuyến, vui lòng truy cập trang thiết bị đầu cuối trong Google Cloud Console . bạn có thể tìm thấy hướng dẫn về cách gửi các yêu cầu mẫu và liên kết đến các tài nguyên khác.

Chạy đường dẫn bằng GPU

Vertex AI hỗ trợ đào tạo bằng nhiều loại máy khác nhau bao gồm hỗ trợ GPU. Xem máy đặc tả tài liệu tham khảo cho các tùy chọn có sẵn.

Chúng tôi đã xác định đường ống của mình để hỗ trợ đào tạo GPU. Tất cả chúng ta cần phải làm là thiết lập use_gpu cờ True. Sau đó, một đường ống sẽ được tạo ra với một spec máy bao gồm một NVIDIA_TESLA_K80 và mã đào tạo mô hình của chúng tôi sẽ sử dụng tf.distribute.MirroredStrategy .

Lưu ý rằng use_gpu cờ không phải là một phần của Vertex hoặc TFX API. Nó chỉ được sử dụng để kiểm soát mã đào tạo trong hướng dẫn này.

# docs_infra: no_execute
runner.run(
    _create_pipeline(
        pipeline_name=PIPELINE_NAME,
        pipeline_root=PIPELINE_ROOT,
        data_root=DATA_ROOT,
        module_file=os.path.join(MODULE_ROOT, _trainer_module_file),
        endpoint_name=ENDPOINT_NAME,
        project_id=GOOGLE_CLOUD_PROJECT,
        region=GOOGLE_CLOUD_REGION,
        # Updated: Use GPUs. We will use a NVIDIA_TESLA_K80 and 
        # the model code will use tf.distribute.MirroredStrategy.
        use_gpu=True))

job = pipeline_jobs.PipelineJob(template_path=PIPELINE_DEFINITION_FILE,
                                display_name=PIPELINE_NAME)
job.run(sync=False)

Bây giờ bạn có thể ghé thăm 'Vertex AI> Đường ống' trong Google Cloud Console để xem sự tiến bộ.

Dọn dẹp

Bạn đã tạo Mô hình và Điểm cuối Vertex AI trong hướng dẫn này. Xin vui lòng xóa các nguồn lực này để tránh bất kỳ khoản phí không mong muốn bằng cách vào thiết bị đầu cuốiundeploying mô hình từ các thiết bị đầu cuối đầu tiên. Sau đó, bạn có thể xóa điểm cuối và mô hình một cách riêng biệt.