sagemaker.train.remote_function.runtime_environment.bootstrap_runtime_environment#
An entry point for runtime environment. This must be kept independent of SageMaker PySDK
Functions
|
Log Environment Variables from the environment and an env_vars_dict. |
|
Log a key-value pair, masking sensitive values if necessary. |
|
Entry point for bootstrap script |
|
Recursively mask sensitive information in a dictionary. |
|
Return the number of CPUs available in the current container. |
|
Return the number of GPUs available in the current container. |
Return the number of neuron cores available in the current container. |
|
|
Serialize the data without wrapping strings in quotes. |
|
Set environment variables for the training job container. |
- sagemaker.train.remote_function.runtime_environment.bootstrap_runtime_environment.log_env_variables(env_vars_dict: Dict[str, Any])[source]#
Log Environment Variables from the environment and an env_vars_dict.
- sagemaker.train.remote_function.runtime_environment.bootstrap_runtime_environment.log_key_value(key: str, value: str)[source]#
Log a key-value pair, masking sensitive values if necessary.
- sagemaker.train.remote_function.runtime_environment.bootstrap_runtime_environment.main(sys_args=None)[source]#
Entry point for bootstrap script
- sagemaker.train.remote_function.runtime_environment.bootstrap_runtime_environment.mask_sensitive_info(data)[source]#
Recursively mask sensitive information in a dictionary.
- sagemaker.train.remote_function.runtime_environment.bootstrap_runtime_environment.num_cpus() int[source]#
Return the number of CPUs available in the current container.
- Returns:
Number of CPUs available in the current container.
- Return type:
int
- sagemaker.train.remote_function.runtime_environment.bootstrap_runtime_environment.num_gpus() int[source]#
Return the number of GPUs available in the current container.
- Returns:
Number of GPUs available in the current container.
- Return type:
int
- sagemaker.train.remote_function.runtime_environment.bootstrap_runtime_environment.num_neurons() int[source]#
Return the number of neuron cores available in the current container.
- Returns:
Number of Neuron Cores available in the current container.
- Return type:
int
- sagemaker.train.remote_function.runtime_environment.bootstrap_runtime_environment.safe_serialize(data)[source]#
Serialize the data without wrapping strings in quotes.
This function handles the following cases: 1. If data is a string, it returns the string as-is without wrapping in quotes. 2. If data is serializable (e.g., a dictionary, list, int, float), it returns
the JSON-encoded string using json.dumps().
If data cannot be serialized (e.g., a custom object), it returns the string representation of the data using str(data).
- Parameters:
data (Any) – The data to serialize.
- Returns:
The serialized JSON-compatible string or the string representation of the input.
- Return type:
str
- sagemaker.train.remote_function.runtime_environment.bootstrap_runtime_environment.set_env(resource_config: Dict[str, Any], distribution: str | None = None, user_nproc_per_node: bool | None = None, output_file: str = '/opt/ml/input/sm_training.env')[source]#
Set environment variables for the training job container.
- Parameters:
resource_config (Dict[str, Any]) – Resource configuration for the training job.
output_file (str) – Output file to write the environment variables.