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

# SageMaker

> W&B를 Amazon SageMaker와 통합하는 방법.

W\&B는 [Amazon SageMaker](https://aws.amazon.com/sagemaker/)와 통합되어 하이퍼파라미터를 자동으로 읽고, 분산 실행되는 Runs를 그룹화하며, 체크포인트에서 실행을 재개할 수 있도록 지원합니다.

## 인증 (Authentication)

W\&B는 트레이닝 스크립트 상대 경로에서 `secrets.env`라는 파일을 찾아 `wandb.init()`이 호출될 때 해당 내용을 환경 변수로 로드합니다. 실험을 시작하는 데 사용하는 스크립트에서 `wandb.sagemaker_auth(path="source_dir")`를 호출하여 `secrets.env` 파일을 생성할 수 있습니다. 이 파일은 반드시 `.gitignore`에 추가해 주세요!

## 기존 Estimator 사용하기

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 tutorial](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>
