Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: CC-BY-SA-4.0

Reference: Amazon SageMaker Containers Environmental Variables

The following build-time environment `variables are also defined by default when you use the [Amazon SageMaker Containers](https://github.com/aws/sagemaker-containers)\. +SM_NUM_CPUS`

SM_NUM_CPUS=32

The SM_NUM_CPUS environment variable contains the number of CPUs available in the current container.

Example:

# Using it in argparse
parser.add_argument('num_cpus', type=int, default=os.environ['SM_NUM_CPUS'])

# Using it as a variable
num_cpus = int(os.environ['SM_NUM_CPUS'])