تدريب Vertex AI والخدمة مع خطوط أنابيب TFX و Vertex

سيقوم هذا البرنامج التعليمي المستند إلى الكمبيوتر المحمول بإنشاء وتشغيل خط أنابيب TFX الذي يقوم بتدريب نموذج ML باستخدام خدمة Vertex AI Training وتنشره على Vertex AI لتقديمه.

ويستند هذا الكمبيوتر الدفتري على خط أنابيب TFX بنينا في بسيط TFX الأنابيب وخطوط الأنابيب فيرتكس التعليمي . إذا لم تكن قد قرأت هذا البرنامج التعليمي حتى الآن ، فيجب عليك قراءته قبل المتابعة مع دفتر الملاحظات هذا.

يمكنك تدريب النماذج على Vertex AI باستخدام AutoML ، أو استخدام تدريب مخصص. في التدريب المخصص ، يمكنك تحديد العديد من أنواع الأجهزة المختلفة لتشغيل وظائف التدريب الخاصة بك ، وتمكين التدريب الموزع ، واستخدام ضبط المعلمة الفائقة ، والتسريع باستخدام وحدات معالجة الرسومات.

يمكنك أيضًا تقديم طلبات التنبؤ من خلال نشر النموذج المدرب على Vertex AI Models وإنشاء نقطة نهاية.

في هذا البرنامج التعليمي ، سنستخدم Vertex AI Training مع وظائف مخصصة لتدريب نموذج في خط أنابيب TFX. سنقوم أيضًا بنشر النموذج لخدمة طلب التنبؤ باستخدام Vertex AI.

ويهدف هذا الكمبيوتر المحمول ليتم تشغيلها على جوجل Colab أو على منصة AI أجهزة الكمبيوتر المحمولة . إذا كنت لا تستخدم أيًا من هؤلاء ، يمكنك ببساطة النقر فوق الزر "تشغيل في Google Colab" أعلاه.

يثبت

إذا كنت قد أكملت بسيط TFX الأنابيب وخطوط الأنابيب فيرتكس دروس ، سيكون لديك مشروع GCP العمل ودلو GCS وهذا هو كل ما نحتاج إليه لهذا البرنامج التعليمي. يرجى قراءة البرنامج التعليمي الأولي أولاً إذا فاتتك.

ثبت حزم بايثون

سنقوم بتثبيت حزم Python المطلوبة بما في ذلك TFX و KFP لتأليف خطوط أنابيب ML وإرسال الوظائف إلى خطوط أنابيب Vertex.

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

هل أعدت تشغيل وقت التشغيل؟

إذا كنت تستخدم Google Colab ، في المرة الأولى التي تقوم فيها بتشغيل الخلية أعلاه ، يجب إعادة تشغيل وقت التشغيل بالنقر فوق الزر "RESTART RUNTIME" أعلاه أو باستخدام قائمة "Runtime> Restart runtime ...". هذا بسبب الطريقة التي يقوم بها كولاب بتحميل الحزم.

إذا لم تكن في Colab ، يمكنك إعادة تشغيل وقت التشغيل بالخلية التالية.

# 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)

تسجيل الدخول إلى Google لهذا دفتر الملاحظات

إذا كنت تقوم بتشغيل هذا الكمبيوتر الدفتري على Colab ، فقم بالمصادقة باستخدام حساب المستخدم الخاص بك:

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

إذا كنت على منصة AI دفاتر الملاحظات، مصادقة مع جوجل الغيمة قبل تشغيل المقطع التالي، عن طريق تشغيل

gcloud auth login

في إطار المحطة الطرفية (والتي يمكنك فتح عبر ملف> جديد في القائمة). ما عليك سوى القيام بذلك مرة واحدة لكل مثيل دفتر ملاحظات.

تحقق من إصدارات الحزمة.

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

قم بإعداد المتغيرات

سنقوم بإعداد بعض المتغيرات المستخدمة لتخصيص خطوط الأنابيب أدناه. المعلومات التالية مطلوبة:

أدخل القيم المطلوبة في الخلية أدناه قبل تشغيله.

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.

مجموعة gcloud استخدام المشروع.

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

تحضير البيانات النموذجية

سوف نستخدم نفس بالمر البطاريق مجموعة البيانات كما بسيط TFX خط أنابيب التعليمي .

توجد أربع سمات رقمية في مجموعة البيانات هذه والتي تم تسويتها بالفعل ليكون لها نطاق [0،1]. سوف نبني نموذج التصنيف الذي يتنبأ species من طيور البطريق.

نحتاج إلى عمل نسختنا الخاصة من مجموعة البيانات. نظرًا لأن TFX ExampleGen تقرأ المدخلات من دليل ، نحتاج إلى إنشاء دليل ونسخ مجموعة البيانات إليه على 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/".

ألق نظرة سريعة على ملف 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".

قم بإنشاء خط أنابيب

سيكون لدينا خط أنابيب تكون مشابهة جدا لخط أنابيب أنشأنا في بسيط TFX الأنابيب وخطوط الأنابيب فيرتكس التعليمي . سيتألف خط الأنابيب من ثلاثة مكونات ، CsvExampleGen و Trainer و Pusher. لكننا سنستخدم عنصر المدرب والدافع الخاص. سينقل مكون المدرب أعباء العمل التدريبية إلى Vertex AI ، وسيقوم مكون Pusher بنشر نموذج ML المدرب إلى Vertex AI بدلاً من نظام الملفات.

يوفر TFX خاص Trainer لإرسال مهام التدريب لخدمة فيرتكس AI التدريب. كل ما عليك القيام به هو استخدام Trainer في حدة الإرشاد بدلا من مستوى Trainer عنصر جنبا إلى جنب مع بعض المعلمات GCP المطلوبة.

في هذا البرنامج التعليمي ، سنقوم بتشغيل مهام Vertex AI Training فقط باستخدام وحدات المعالجة المركزية أولاً ثم باستخدام وحدة معالجة الرسومات.

كما يوفر TFX خاص Pusher لتحميل النموذج لنماذج فيرتكس AI. Pusher سيخلق الموارد فيرتكس AI نقطة النهاية لخدمة perdictions على الانترنت أيضا. انظر الوثائق فيرتكس AI لمعرفة المزيد عن التنبؤات عبر الإنترنت التي توفرها فيرتكس AI.

اكتب كود النموذج.

النموذج نفسه هو مماثل تقريبا وفقا للنموذج بسيط TFX خط أنابيب التعليمي .

وسوف نضيف _get_distribution_strategy() وظيفة مما يخلق استراتيجية التوزيع TensorFlow ويتم استخدامه في run_fn استخدام MirroredStrategy إذا GPU هو متاح.

_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

انسخ ملف الوحدة النمطية إلى GCS والذي يمكن الوصول إليه من مكونات خط الأنابيب.

بخلاف ذلك ، قد ترغب في إنشاء صورة حاوية بما في ذلك ملف الوحدة النمطية واستخدام الصورة لتشغيل خط الأنابيب ومهام تدريب النظام الأساسي لمنظمة العفو الدولية.

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/".

اكتب تعريف خط الأنابيب

سنحدد وظيفة لإنشاء خط أنابيب TFX. أنه يحتوي على نفس مكونات ثلاثة كما هو الحال في بسيط TFX خط أنابيب تعليمي ، ولكن نحن نستخدم Trainer و Pusher عنصرا في وحدة الإرشاد GCP.

tfx.extensions.google_cloud_ai_platform.Trainer يتصرف مثل العادية Trainer ، ولكن فقط يتحرك حساب لتدريب نموذج للسحابة. تطلق وظيفة مخصصة في خدمة Vertex AI Training ، وسوف ينتظر مكون المدرب في نظام التنسيق حتى تكتمل وظيفة Vertex AI Training.

tfx.extensions.google_cloud_ai_platform.Pusher يخلق فيرتكس AI نموذج وفيرتكس AI نقطة النهاية باستخدام نموذج المدربين.

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)

قم بتشغيل خط الأنابيب على خطوط أنابيب Vertex.

سوف نستخدم فيرتكس خطوط الأنابيب لتشغيل خط أنابيب كما فعلنا في بسيط TFX الأنابيب وخطوط الأنابيب فيرتكس التعليمي .

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))

ويمكن تقديم ملف تعريف إنشاؤها باستخدام جوجل الغيمة العميل aiplatform في google-cloud-aiplatform الحزمة.

# 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)

الآن يمكنك زيارة 'فيرتكس AI> أنابيب النفط في Google Cloud Console لرؤية التقدم.

اختبار مع طلب التنبؤ

وبمجرد أن يكمل خط أنابيب، وسوف تجد نموذجا نشر في واحدة من نقاط النهاية في "فيرتكس AI> النهايات. نحتاج إلى معرفة معرف نقطة النهاية لإرسال طلب تنبؤ إلى نقطة النهاية الجديدة. وهذا يختلف عن اسم نقطة النهاية دخلنا أعلاه. يمكنك العثور على معرف في الصفحة نقاط النهاية في Google Cloud Console ، يبدو أن عددا طويلة جدا.

عيّن ENDPOINT_ID أدناه قبل تشغيله.

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.

نحن نستخدم نفس عميل النظام الأساسي لإرسال طلب إلى نقطة النهاية. سوف نرسل طلب تنبؤ لتصنيف أنواع البطريق. المدخلات هي الميزات الأربع التي استخدمناها ، وسيرجع النموذج ثلاث قيم ، لأن نموذجنا ينتج قيمة واحدة لكل نوع.

على سبيل المثال ، المثال التالي المحدد له أكبر قيمة في الفهرس "2" وسيطبع "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]))

للحصول على معلومات مفصلة حول التنبؤ عبر الإنترنت، يرجى زيارة الصفحة نهايات في Google Cloud Console . يمكنك العثور على دليل حول إرسال نماذج من الطلبات وروابط لمزيد من الموارد.

قم بتشغيل خط الأنابيب باستخدام وحدة معالجة الرسومات

يدعم Vertex AI التدريب باستخدام أنواع مختلفة من الأجهزة بما في ذلك دعم وحدات معالجة الرسومات. انظر المرجع آلة المواصفات للخيارات المتاحة.

لقد حددنا بالفعل خط الأنابيب الخاص بنا لدعم تدريب GPU. كل ما عليك القيام به هو وضع use_gpu العلم إلى True. ثم سيتم إنشاء خط أنابيب مع المواصفات الجهاز بما في ذلك واحد NVIDIA_TESLA_K80 ولدينا كود تدريبية نموذجية سوف تستخدم tf.distribute.MirroredStrategy .

لاحظ أن use_gpu العلم ليس جزءا من API فيرتكس أو TFX. يتم استخدامه فقط للتحكم في رمز التدريب في هذا البرنامج التعليمي.

# 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)

الآن يمكنك زيارة 'فيرتكس AI> أنابيب النفط في Google Cloud Console لرؤية التقدم.

تنظيف

لقد قمت بإنشاء Vertex AI Model and Endpoint في هذا البرنامج التعليمي. يرجى حذف هذه الموارد لتجنب أي اتهامات غير المرغوب فيها عن طريق الذهاب إلى النهايات وundeploying نموذج من نقطة النهاية أولا. ثم يمكنك حذف نقطة النهاية والنموذج بشكل منفصل.