The Command Line
The Command Line
Below is a list of all the available commands ๐ Accelerate with their parameters
accelerate config
Command:
accelerate config
or accelerate-config
Launches a series of prompts to create and save a default_config.yml
configuration file for your training system. Should always be ran first on your machine.
Usage:
Copied
Optional Arguments:
--config_file CONFIG_FILE
(str
) โ The path to use to store the config file. Will default to a file named default_config.yaml in the cache location, which is the content of the environmentHF_HOME
suffixed with โaccelerateโ, or if you donโt have such an environment variable, your cache directory (~/.cache
or the content ofXDG_CACHE_HOME
) suffixed withboincai
.-h
,--help
(bool
) โ Show a help message and exit
accelerate config default
Command:
accelerate config default
or accelerate-config default
Create a default config file for Accelerate with only a few flags set.
Usage:
Copied
Optional Arguments:
--config_file CONFIG_FILE
(str
) โ The path to use to store the config file. Will default to a file named default_config.yaml in the cache location, which is the content of the environmentHF_HOME
suffixed with โaccelerateโ, or if you donโt have such an environment variable, your cache directory (~/.cache
or the content ofXDG_CACHE_HOME
) suffixed withboincai
.-h
,--help
(bool
) โ Show a help message and exit--mixed_precision {no,fp16,bf16}
(str
) โ Whether or not to use mixed precision training. Choose between FP16 and BF16 (bfloat16) training. BF16 training is only supported on Nvidia Ampere GPUs and PyTorch 1.10 or later.
accelerate config update
Command:
accelerate config update
or accelerate-config update
Update an existing config file with the latest defaults while maintaining the old configuration.
Usage:
Copied
Optional Arguments:
--config_file CONFIG_FILE
(str
) โ The path to the config file to update. Will default to a file named default_config.yaml in the cache location, which is the content of the environmentHF_HOME
suffixed with โaccelerateโ, or if you donโt have such an environment variable, your cache directory (~/.cache
or the content ofXDG_CACHE_HOME
) suffixed withboincai
.-h
,--help
(bool
) โ Show a help message and exit
accelerate env
Command:
accelerate env
or accelerate-env
or python -m accelerate.commands.env
Lists the contents of the passed ๐ Accelerate configuration file. Should always be used when opening an issue on the GitHub repository.
Usage:
Copied
Optional Arguments:
--config_file CONFIG_FILE
(str
) โ The path to use to store the config file. Will default to a file named default_config.yaml in the cache location, which is the content of the environmentHF_HOME
suffixed with โaccelerateโ, or if you donโt have such an environment variable, your cache directory (~/.cache
or the content ofXDG_CACHE_HOME
) suffixed withboincai
.-h
,--help
(bool
) โ Show a help message and exit
accelerate launch
Command:
accelerate launch
or accelerate-launch
or python -m accelerate.commands.launch
Launches a specified script on a distributed system with the right parameters.
Usage:
Copied
Positional Arguments:
{training_script}
โ The full path to the script to be launched in parallel--{training_script-argument-1}
โ Arguments of the training script
Optional Arguments:
-h
,--help
(bool
) โ Show a help message and exit--config_file CONFIG_FILE
(str
)โ The config file to use for the default values in the launching script.-m
,--module
(bool
) โ Change each process to interpret the launch script as a Python module, executing with the same behavior as โpython -mโ.--no_python
(bool
) โ Skip prepending the training script with โpythonโ - just execute it directly. Useful when the script is not a Python script.--debug
(bool
) โ Whether to print out the torch.distributed stack trace when something fails.-q
,--quiet
(bool
) โ Silence subprocess errors from the launch stack trace to only show the relevant tracebacks. (Only applicable to DeepSpeed and single-process configurations).
The rest of these arguments are configured through accelerate config
and are read in from the specified --config_file
(or default configuration) for their values. They can also be passed in manually.
Hardware Selection Arguments:
--cpu
(bool
) โ Whether or not to force the training on the CPU.--multi_gpu
(bool
) โ Whether or not this should launch a distributed GPU training.--tpu
(bool
) โ Whether or not this should launch a TPU training.--ipex
(bool
) โ Whether or not this should launch an Intel Pytorch Extension (IPEX) training.
Resource Selection Arguments:
The following arguments are useful for fine-tuning how available hardware should be used
--mixed_precision {no,fp16,bf16}
(str
) โ Whether or not to use mixed precision training. Choose between FP16 and BF16 (bfloat16) training. BF16 training is only supported on Nvidia Ampere GPUs and PyTorch 1.10 or later.--num_processes NUM_PROCESSES
(int
) โ The total number of processes to be launched in parallel.--num_machines NUM_MACHINES
(int
) โ The total number of machines used in this training.--num_cpu_threads_per_process NUM_CPU_THREADS_PER_PROCESS
(int
) โ The number of CPU threads per process. Can be tuned for optimal performance.
Training Paradigm Arguments:
The following arguments are useful for selecting which training paradigm to use.
--use_deepspeed
(bool
) โ Whether or not to use DeepSpeed for training.--use_fsdp
(bool
) โ Whether or not to use FullyShardedDataParallel for training.--use_megatron_lm
(bool
) โ Whether or not to use Megatron-LM for training.--use_xpu
(bool
) โ Whether to use IPEX plugin to speed up training on XPU specifically.
Distributed GPU Arguments:
The following arguments are only useful when multi_gpu
is passed or multi-gpu training is configured through accelerate config
:
--gpu_ids
(str
) โ What GPUs (by id) should be used for training on this machine as a comma-seperated list--same_network
(bool
) โ Whether all machines used for multinode training exist on the same local network.--machine_rank MACHINE_RANK
(int
) โ The rank of the machine on which this script is launched.--main_process_ip MAIN_PROCESS_IP
(str
) โ The IP address of the machine of rank 0.--main_process_port MAIN_PROCESS_PORT
(int
) โ The port to use to communicate with the machine of rank 0.--rdzv_backend
(str
) โ The rendezvous method to use, such as โstaticโ or โc10dโ--rdzv_conf
(str
) โ Additional rendezvous configuration (<key1>=<value1>,<key2>=<value2>,โฆ).--max_restarts
(int
) โ Maximum number of worker group restarts before failing.--monitor_interval
(float
) โ Interval, in seconds, to monitor the state of workers.
TPU Arguments:
The following arguments are only useful when tpu
is passed or TPU training is configured through accelerate config
:
--main_training_function MAIN_TRAINING_FUNCTION
(str
) โ The name of the main function to be executed in your script.--downcast_bf16
(bool
) โ Whether when using bf16 precision on TPUs if both float and double tensors are cast to bfloat16 or if double tensors remain as float32.
DeepSpeed Arguments:
The following arguments are only useful when use_deepspeed
is passed or deepspeed
is configured through accelerate config
:
--deepspeed_config_file
(str
) โ DeepSpeed config file.--zero_stage
(int
) โ DeepSpeedโs ZeRO optimization stage.--offload_optimizer_device
(str
) โ Decides where (none|cpu|nvme) to offload optimizer states.--offload_param_device
(str
) โ Decides where (none|cpu|nvme) to offload parameters.--gradient_accumulation_steps
(int
) โ No of gradient_accumulation_steps used in your training script.--gradient_clipping
(float
) โ Gradient clipping value used in your training script.--zero3_init_flag
(str
) โ Decides Whether (true|false) to enabledeepspeed.zero.Init
for constructing massive models. Only applicable with DeepSpeed ZeRO Stage-3.--zero3_save_16bit_model
(str
) โ Decides Whether (true|false) to save 16-bit model weights when using ZeRO Stage-3. Only applicable with DeepSpeed ZeRO Stage-3.--deepspeed_hostfile
(str
) โ DeepSpeed hostfile for configuring multi-node compute resources.--deepspeed_exclusion_filter
(str
) โ DeepSpeed exclusion filter string when using mutli-node setup.--deepspeed_inclusion_filter
(str
) โ DeepSpeed inclusion filter string when using mutli-node setup.--deepspeed_multinode_launcher
(str
) โ DeepSpeed multi-node launcher to use.
Fully Sharded Data Parallelism Arguments:
The following arguments are only useful when use_fdsp
is passed or Fully Sharded Data Parallelism is configured through accelerate config
:
--fsdp_offload_params
(str
) โ Decides Whether (true|false) to offload parameters and gradients to CPU.--fsdp_min_num_params
(int
) โ FSDPโs minimum number of parameters for Default Auto Wrapping.--fsdp_sharding_strategy
(int
) โ FSDPโs Sharding Strategy.--fsdp_auto_wrap_policy
(str
) โ FSDPโs auto wrap policy.--fsdp_transformer_layer_cls_to_wrap
(str
) โ Transformer layer class name (case-sensitive) to wrap, e.g,BertLayer
,GPTJBlock
,T5Block
โฆ--fsdp_backward_prefetch_policy
(str
) โ FSDPโs backward prefetch policy.--fsdp_state_dict_type
(str
) โ FSDPโs state dict type.
Megatron-LM Arguments:
The following arguments are only useful when use_megatron_lm
is passed or Megatron-LM is configured through accelerate config
:
--megatron_lm_tp_degree
(โ) โ Megatron-LMโs Tensor Parallelism (TP) degree.--megatron_lm_pp_degree
(โ) โ Megatron-LMโs Pipeline Parallelism (PP) degree.--megatron_lm_num_micro_batches
(โ) โ Megatron-LMโs number of micro batches when PP degree > 1.--megatron_lm_sequence_parallelism
(โ) โ Decides Whether (true|false) to enable Sequence Parallelism when TP degree > 1.--megatron_lm_recompute_activations
(โ) โ Decides Whether (true|false) to enable Selective Activation Recomputation.--megatron_lm_use_distributed_optimizer
(โ) โ Decides Whether (true|false) to use distributed optimizer which shards optimizer state and gradients across Data Pralellel (DP) ranks.--megatron_lm_gradient_clipping
(โ) โ Megatron-LMโs gradient clipping value based on global L2 Norm (0 to disable).
AWS SageMaker Arguments:
The following arguments are only useful when training in SageMaker
--aws_access_key_id AWS_ACCESS_KEY_ID
(str
) โ The AWS_ACCESS_KEY_ID used to launch the Amazon SageMaker training job--aws_secret_access_key AWS_SECRET_ACCESS_KEY
(str
) โ The AWS_SECRET_ACCESS_KEY used to launch the Amazon SageMaker training job
accelerate estimate-memory
Command:
accelerate estimate-memory
or accelerate-estimate-memory
or python -m accelerate.commands.estimate
Estimates the total vRAM a particular model hosted on the Hub needs to be loaded in with an estimate for training. Requires that boincai_hub
be installed.
When performing inference, typically add โค20% to the result as overall allocation as referenced here. We will have more extensive estimations in the future that will automatically be included in the calculation.
Usage:
Copied
Required Arguments:
MODEL_NAME
(str
)โ The model name on the BOINC AI Hub
Optional Arguments:
--library_name {timm,transformers}
(str
) โ The library the model has an integration with, such astransformers
, needed only if this information is not stored on the Hub--dtypes {float32,float16,int8,int4}
([{float32,float16,int8,int4} ...]
) โ The dtypes to use for the model, must be one (or many) offloat32
,float16
,int8
, andint4
--trust_remote_code
(bool
) โ Whether or not to allow for custom models defined on the Hub in their own modeling files. This option should only be passed for repositories you trust and in which you have read the code, as it will execute code present on the Hub on your local machine.
accelerate tpu-config
accelerate tpu-config
Usage:
Copied
Optional Arguments:
-h
,--help
(bool
) โ Show a help message and exit
Config Arguments:
Arguments that can be configured through accelerate config
.
--config_file
(str
) โ Path to the config file to use for accelerate.--tpu_name
(str
) โ The name of the TPU to use. If not specified, will use the TPU specified in the config file.--tpu_zone
(str
) โ The zone of the TPU to use. If not specified, will use the zone specified in the config file.
TPU Arguments:
Arguments for options ran inside the TPU.
--command_file
(str
) โ The path to the file containing the commands to run on the pod on startup.--command
(str
) โ A command to run on the pod. Can be passed multiple times.--install_accelerate
(bool
) โ Whether to install accelerate on the pod. Defaults to False.--accelerate_version
(str
) โ The version of accelerate to install on the pod. If not specified, will use the latest pypi version. Specify โdevโ to install from GitHub.--debug
(bool
) โ If set, will print the command that would be run instead of running it.
accelerate test
accelerate test
or accelerate-test
Runs accelerate/test_utils/test_script.py
to verify that ๐ Accelerate has been properly configured on your system and runs.
Usage:
Copied
Optional Arguments:
--config_file CONFIG_FILE
(str
) โ The path to use to store the config file. Will default to a file named default_config.yaml in the cache location, which is the content of the environmentHF_HOME
suffixed with โaccelerateโ, or if you donโt have such an environment variable, your cache directory (~/.cache
or the content ofXDG_CACHE_HOME
) suffixed withboincai
.-h
,--help
(bool
) โ Show a help message and exit
Last updated