> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-docs-weave-byob-note.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> AWSインフラストラクチャー上で実験管理、メトリクスのログ記録、モデル管理を行うために、W&B を Amazon SageMaker と統合します。

# SageMaker

W\&B は [Amazon SageMaker](https://aws.amazon.com/sagemaker/) と統合されており、ハイパーパラメーターを自動的に読み取り、分散 run をグループ化し、チェックポイントから run を再開します。

<div id="authentication">
  ## 認証
</div>

W\&B は、トレーニングスクリプトを基準とした相対パスにある `secrets.env` という名前のファイルを探し、`wandb.init()` が呼び出されるとその内容を環境変数として読み込みます。Experiments の起動に使用するスクリプトで `wandb.sagemaker_auth(path="source_dir")` を呼び出すと、`secrets.env` ファイルを生成できます。必ずこのファイルを `.gitignore` に追加してください！

<div id="existing-estimators">
  ## 既存の Estimator
</div>

SageMaker の事前設定済みの Estimator のいずれかを使用している場合は、wandb を含む `requirements.txt` をソースディレクトリに追加する必要があります

```text theme={null}
wandb
```

Python 2 で実行されている estimator を使用している場合は、wandb をインストールする前に、この [wheel](https://pythonwheels.com) から `psutil` を直接インストールする必要があります。

```text theme={null}
https://wheels.galaxyproject.org/packages/psutil-5.4.8-cp27-cp27mu-manylinux1_x86_64.whl
wandb
```

GitHub の[完全な例](https://github.com/wandb/examples/tree/master/examples/pytorch/pytorch-cifar10-sagemaker)を確認し、詳細は[ブログ](https://wandb.ai/site/articles/running-sweeps-with-sagemaker)をご覧ください。

また、SageMaker と W\&B を使って感情分析器をデプロイする方法については、[Deploy Sentiment Analyzer Using SageMaker and W\&B チュートリアル](https://wandb.ai/authors/sagemaker/reports/Deploy-Sentiment-Analyzer-Using-SageMaker-and-W-B--VmlldzoxODA1ODE)も参照できます。

<Warning>
  W\&B の sweep agent が SageMaker ジョブ内で想定どおりに動作するのは、SageMaker インテグレーションがオフになっている場合に限られます。`wandb.init()` の呼び出しを次のように変更して、SageMaker インテグレーションをオフにしてください。

  ```python theme={null}
  wandb.init(..., settings=wandb.Settings(sagemaker_disable=True))
  ```
</Warning>
