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

> Integrate W&B with Amazon SageMaker for experiment tracking, metric logging, and model management on AWS infrastructure.

# SageMaker

W\&B integrates with [Amazon SageMaker](https://aws.amazon.com/sagemaker/) to automatically read hyperparameters, group distributed runs, and resume runs from checkpoints.

## Authentication

W\&B looks for a file named `secrets.env` relative to the training script and loads its contents into the environment when you call `wandb.init()`. To generate a `secrets.env` file, call `wandb.sagemaker_auth(path="source_dir")` in the script you use to launch your experiments. Add this file to your `.gitignore`.

## Existing estimators

If you're using one of SageMaker's preconfigured estimators, add a `requirements.txt` file to your source directory that includes `wandb`:

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

If you're using an estimator that runs Python 2, install `psutil` from this [wheel](https://pythonwheels.com) before you install `wandb`:

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

For a complete example, see the [SageMaker example on GitHub](https://github.com/wandb/examples/tree/master/examples/pytorch/pytorch-cifar10-sagemaker). For more about running sweeps with SageMaker, see the [W\&B blog post on SageMaker sweeps](https://wandb.ai/site/articles/running-sweeps-with-sagemaker).

For a tutorial on deploying a sentiment analyzer with SageMaker and W\&B, see [Deploy Sentiment Analyzer Using SageMaker and W\&B](https://wandb.ai/authors/sagemaker/reports/Deploy-Sentiment-Analyzer-Using-SageMaker-and-W-B--VmlldzoxODA1ODE).

<Warning>
  The W\&B sweep agent works correctly inside a SageMaker job only when the SageMaker integration is turned off. To turn off the SageMaker integration, update your call to `wandb.init()`:

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