sagemaker.core.modules.train.container_drivers.scripts.environment#

This module is used to define the environment variables for the training job container.

Functions

deserialize_hyperparameters(hyperparameters)

Deserialize hyperparameters from string to their original types.

log_env_variables(env_vars_dict)

Log Environment Variables from the environment and an env_vars_dict.

log_key_value(key, value)

Log a key-value pair, masking sensitive values if necessary.

main()

Main function to set the environment variables for the training job container.

mask_sensitive_info(data)

Recursively mask sensitive information in a dictionary.

num_cpus()

Return the number of CPUs available in the current container.

num_gpus()

Return the number of GPUs available in the current container.

num_neurons()

Return the number of neuron cores available in the current container.

set_env(resource_config, input_data_config, ...)

Set environment variables for the training job container.

sagemaker.core.modules.train.container_drivers.scripts.environment.deserialize_hyperparameters(hyperparameters: Dict[str, str]) Dict[str, Any][source]#

Deserialize hyperparameters from string to their original types.

Parameters:

hyperparameters (Dict[str, str]) – Hyperparameters as strings.

Returns:

Hyperparameters as their original types.

Return type:

Dict[str, Any]

sagemaker.core.modules.train.container_drivers.scripts.environment.log_env_variables(env_vars_dict: Dict[str, Any])[source]#

Log Environment Variables from the environment and an env_vars_dict.

sagemaker.core.modules.train.container_drivers.scripts.environment.log_key_value(key: str, value: str)[source]#

Log a key-value pair, masking sensitive values if necessary.

sagemaker.core.modules.train.container_drivers.scripts.environment.main()[source]#

Main function to set the environment variables for the training job container.

sagemaker.core.modules.train.container_drivers.scripts.environment.mask_sensitive_info(data)[source]#

Recursively mask sensitive information in a dictionary.

sagemaker.core.modules.train.container_drivers.scripts.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.core.modules.train.container_drivers.scripts.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.core.modules.train.container_drivers.scripts.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.core.modules.train.container_drivers.scripts.environment.set_env(resource_config: Dict[str, Any], input_data_config: Dict[str, Any], hyperparameters_config: Dict[str, Any], 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.

  • input_data_config (Dict[str, Any]) – Input data configuration for the training job.

  • hyperparameters_config (Dict[str, Any]) – Hyperparameters configuration for the training job.

  • output_file (str) – Output file to write the environment variables.