Cloud TPU 모니터링 및 로깅 대시보드

Cloud TPU 모니터링 및 디버깅 대시보드 저장소에는 TPU VM에서 실행되는 워크플로를 모니터링하고 디버깅하는 데 필요한 모든 인프라 및 로직이 포함되어 있습니다. 여기에는 구성 파일을 사용하여 Google Cloud 인프라를 정의하고 관리하는 오픈소스 도구인 Terraform이 필요합니다.

Monitoring 대시보드

모니터링 대시보드에 다음 Cloud TPU 측정항목이 표시됩니다.

  • TPU 워커의 CPU 사용률: cpu/utilization
  • TPU VM의 메모리 사용량: memory/usage
  • 네트워크를 통해 포드에서 수신한 네트워크 바이트: network/received_bytes_count
  • 포드가 네트워크를 통해 전송한 네트워크 바이트: network/sent_bytes_count
  • TPU 칩의 TensorCore 유휴 기간: tpu/tensorcore/idle_duration

Cloud Monitoring은 측정항목 데이터를 자동으로 생성합니다. 모니터링 대시보드를 보려면 Google Cloud 콘솔로 이동하여 Monitoring을 선택한 후 대시보드를 선택합니다. 대시보드 목록에서 GCE - TPU 모니터링 대시보드를 선택합니다. Cloud TPU 모니터링 대시보드는 각각 측정항목 데이터를 표시하는 여러 개의 창으로 구성됩니다. 각 Cloud TPU 측정항목에 대해 대시보드에 현재 측정항목 값, 평균, 최댓값이 개별 창에 표시됩니다. 평균 및 최대 창을 사용하면 추가 조사를 위해 이상점 TPU VM을 식별할 수 있습니다.

Cloud Monitoring Google Cloud 콘솔에서 측정항목 탐색기를 사용하여 TPU 측정항목을 볼 수도 있습니다. 자세한 내용은 Cloud TPU VM 모니터링을 참조하세요.

로깅 대시보드

로깅 대시보드에는 두 가지 섹션이 표시됩니다.

  1. 로그 측정항목: 각 TPU VM 작업자에 대해 수집된 스택 트레이스 항목 수를 표시합니다.
  2. 로그 패널: 심각도, 타임스탬프, 항목 요약 열이 있는 모든 스택 트레이스 항목을 표시합니다. 이 로그 패널을 문자열 또는 TPU 워커 라벨(예: node_id, worker_id)로 필터링할 수 있습니다. 예를 들어 resource.labels.node_id:"testing" 필터를 추가하면 ID가 'testing'로 설정된 TPU VM 워커에 대해 수집된 모든 trace 항목이 표시됩니다.

Cloud Logging은 Google Cloud 서비스, 타사 서비스, ML 프레임워크, 코드에서 생성된 로그 항목을 수집합니다. 오류 또는 예외가 발생하거나 워크로드가 응답하지 않을 때 Python 스택 트레이스를 작성하도록 cloud-tpu-diagnostics PyPi 패키지를 설치할 수 있습니다. 자세한 내용은 Cloud TPU VM 디버깅을 참조하세요.

로깅 대시보드를 보려면 Google Cloud 콘솔로 이동하여 Monitoring, 대시보드를 차례로 선택합니다. 대시보드 목록에서 GCE - TPU 로깅 대시보드를 선택합니다.

측정항목 및 로깅 대시보드 구성

측정항목 및 로깅 대시보드를 구성하려면 다음 안내를 따르세요.

대시보드 저장소 클론

Cloud TPU Monitoring 및 Debugging GitHub 저장소에서 직접 또는 명령줄에서 저장소를 클론할 수 있습니다.

git clone https://github.com/google/cloud-tpu-monitoring-debugging.git

Terraform 설치

  1. 로컬 머신에 Terraform을 설치하세요.
  2. terraform init를 실행하여 필요한 플러그인을 추가하고 .terraform 디렉터리를 만듭니다.
  3. terraform init –upgrade를 실행하여 사용 가능한 업데이트를 설치합니다.

모니터링 및 로깅 권한 구성

Google Cloud 프로젝트에 모니터링 리소스를 배포하려면 모니터링 관리자, 모니터링 대시보드 구성 편집자, 로깅 관리자 역할이 필요합니다. 모니터링 역할에 대한 자세한 내용은 Cloud Monitoring에 액세스 권한 부여를 참조하세요.

Cloud Storage 버킷 만들기

Terraform 상태 파일을 저장할 Cloud Storage 버킷을 만듭니다. 기존 Cloud Storage 버킷을 사용할 수도 있습니다. Cloud Storage 버킷을 사용하면 여러 사용자가 동시에 Terraform을 실행하고 동일한 인프라에 액세스할 수 있습니다.

  1. Cloud Shell에서 Cloud Storage 버킷을 만듭니다.

    gsutil mb gs://${GCS_BUCKET_NAME}
    
  2. 객체 버전 관리를 사용 설정하여 배포 기록을 유지합니다. 객체 버전 관리를 사용 설정하면 스토리지 비용이 늘어납니다. 하지만 객체 수명 주기 관리를 구성하여 이전 상태 버전을 삭제하면 이 비용을 줄일 수 있습니다.

    gsutil versioning set on gs://${GCS_BUCKET_NAME}
    

Terraform 초기화

저장소의 gcp_resources/gce 디렉터리 내에서 terraform init을 실행합니다. 이 명령어를 실행하면 Terraform 상태 파일을 저장할 Cloud Storage 버킷의 이름을 입력하라는 메시지가 표시됩니다.

모니터링 및 로깅 대시보드 배포

gcp_resources/gce 디렉터리 내에서 terraform apply를 실행하여 Google Cloud 프로젝트의 모니터링 및 로깅 대시보드를 배포합니다. 이 명령어는 다음 변수의 값을 제공하라는 메시지를 표시합니다.

  • var.monitoring_dashboard_config
  • var.project_name
  • var.stack_trace_bucket_config

모니터링 대시보드만 배포하려면 gcp_resources/gce/dashboard/monitoring_dashboard 디렉터리 내에서 terraform initterraform apply를 실행합니다. 마찬가지로 gcp_resources/gce/dashboard/logging_dashboard 디렉터리 내에서 이 명령어를 실행하여 로깅 대시보드만 배포합니다.

구성 예시

terraform apply를 실행하면 Terraform에서 일부 구성 변수 값을 묻는 메시지가 표시됩니다. 이 섹션에서는 사용할 수 있는 몇 가지 구성 예시를 제공합니다. 각 예시는 terraform apply 명령어로 표시된 출력과 각 구성 변수에 대해 굵은 글자로 추천된 값을 보여줍니다. 입력은 중괄호 ('{}')로 묶인 JSON 형식이어야 합니다.

예 1

이 예시에서는 Google Cloud 프로젝트 이름을 지정하고 나머지 구성에 기본값을 사용합니다.

var.project_name
  Name of gcp project

  Enter a value: <gcp_project_name>

var.stack_trace_bucket_config
    Configuration to create a log bucket to store stack traces:
    {
      "bucket_name": "name of log bucket to create",
      "retention_days": &lt;number of days to retain stack traces, default to 30 days if not set&gt;
    }
    Enter {} to not create separate bucket for stack traces.

  Enter a value: {}

var.monitoring_dashboard_config
    Configuration for monitoring dashboard:
    {
      "node_prefix": "prefix used to generate the node name in multislice node provision, default to empty string",
      "outlier_count": &lt;the number of outliers to show on dashboard, default to 10 if not set&gt;
    }
    Enter {} to set default configuration for monitoring dashboard.

  Enter a value: {}

예 2

이 예시에서는 5개의 이상점 TPU VM을 표시하도록 대시보드를 구성합니다.

var.project_name
  Name of gcp project

  Enter a value: <gcp_project_name>

var.stack_trace_bucket_config
    Configuration to create a log bucket to store stack traces:
    {
      "bucket_name": "name of log bucket to create",
      "retention_days": &lt;number of days to retain stack traces, default to 30 days if not set&gt;
    }
    Enter {} to not create separate bucket for stack traces.

  Enter a value: {}

var.monitoring_dashboard_config
    Configuration for monitoring dashboard:
    {
    "node_prefix": "prefix used to generate the node name in multislice node provision, default to empty string",
      "outlier_count": &lt;number of outliers to show on dashboard, default to 10 if not set&gt;
    }
    Enter {} to set default configuration for monitoring dashboard.

  Enter a value: {"outlier_count":5}

예 3

이 구성은 대시보드에서 생성된 노드 이름의 프리픽스로 'test'를 사용하여 10개의 이상점 TPU VM을 표시하는 대시보드를 만듭니다.

var.project_name
  Name of gcp project

  Enter a value: <gcp_project_name>

var.stack_trace_bucket_config
    Configuration to create a log bucket to store stack traces:
    {
      "bucket_name": "name of log bucket to create",
      "retention_days": &lt;number of days to retain stack traces, default to 30 days if not set&gt;
    }
    Enter {} to not create separate bucket for stack traces.

  Enter a value: {}

var.monitoring_dashboard_config
    Configuration for monitoring dashboard:
    {
      "node_prefix": "prefix used to generate the node name in multislice node provision, default to empty string",
      "outlier_count": &ltnumber of outliers to show on dashboard, default to 10 if not set&gt;
    }
    Enter {} to set default configuration for monitoring dashboard.

  Enter a value: {"node_prefix":"test"}

예 4

이 구성은 대시보드에서 생성된 노드 이름의 프리픽스로 'test'를 사용하여 5개의 이상점 VM을 표시하는 대시보드를 만듭니다.

var.project_name
  Name of gcp project

  Enter a value: <gcp_project_name>

var.stack_trace_bucket_config
    Configuration to create a log bucket to store stack traces:
    {
      "bucket_name": "name of log bucket to create",
      "retention_days": &lt;number of days to retain stack traces, default to 30 days if not set&gt;
    }
    Enter {} to not create separate bucket for stack traces.

  Enter a value: {}

var.monitoring_dashboard_config
    Configuration for monitoring dashboard:
    {
    "node_prefix": "prefix used to generate the node name in multislice node provision, default to empty string",
      "outlier_count": "number of outliers to show on dashboard, default to 10 if not set"
    }
    Enter {} to set default configuration for monitoring dashboard.

  Enter a value: {"node_prefix":"test", "outlier_count":5}

예시 5

이 예시에서는 스택 트레이스를 저장하도록 Cloud Storage 버킷을 구성합니다. 스택 trace에는 기본 30일 보관 정책이 있습니다.

var.project_name
  Name of gcp project

  Enter a value: <gcp_project_name>

var.stack_trace_bucket_config
    Configuration to create a log bucket to store stack traces:
    {
      "bucket_name": "name of log bucket to create",
      "retention_days": &lt;number of days to retain stack traces, default to 30 days if not set&gt;
    }
    Enter {} to not create separate bucket for stack traces.

  Enter a value: {"bucket_name":"stack_trace_log_bucket"}

var.monitoring_dashboard_config
    Configuration for monitoring dashboard:
    {
    "node_prefix": "prefix used to generate the node name in multislice node provision, default to empty string",
      "outlier_count": "number of outliers to show on dashboard, default to 10 if not set"
    }
    Enter {} to set default configuration for monitoring dashboard.

  Enter a value: {}

예시 6

이 예시에서는 보관 기간이 20일인 Cloud Storage 버킷을 구성합니다.

var.project_name
  Name of gcp project

  Enter a value: <gcp_project_name>

var.stack_trace_bucket_config
    Configuration to create a log bucket to store stack traces:
    {
      "bucket_name": "name of log bucket to create",
      "retention_days": &lt;number of days to retain stack traces, default to 30 days if not set&gt;
    }
    Enter {} to not create separate bucket for stack traces.

  Enter a value: {"bucket_name":"stack_trace_log_bucket", "retention_days":20}

var.monitoring_dashboard_config
    Configuration for monitoring dashboard:
    {
    "node_prefix": "prefix used to generate the node name in multislice node provision, default to empty string",
      "outlier_count": "number of outliers to show on dashboard, default to 10 if not set"
    }
    Enter {} to set default configuration for monitoring dashboard.

  Enter a value: {}