| 1 |
<!--Copyright 2022 The HuggingFace Team. All rights reserved. |
| 2 |
|
| 3 |
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
| 4 |
the License. You may obtain a copy of the License at |
| 5 |
|
| 6 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 7 |
|
| 8 |
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
| 9 |
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| 10 |
specific language governing permissions and limitations under the License. |
| 11 |
|
| 12 |
⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be |
| 13 |
rendered properly in your Markdown viewer. |
| 14 |
--> |
| 15 |
|
| 16 |
# Installation |
| 17 |
|
| 18 |
Before you start, you will need to setup your environment, install the appropriate packages, and configure Accelerate. Accelerate is tested on **Python 3.8+**. |
| 19 |
|
| 20 |
Accelerate is available on pypi and conda, as well as on GitHub. Details to install from each are below: |
| 21 |
|
| 22 |
## pip |
| 23 |
|
| 24 |
To install Accelerate from pypi, perform: |
| 25 |
|
| 26 |
```bash |
| 27 |
pip install accelerate |
| 28 |
``` |
| 29 |
|
| 30 |
## conda |
| 31 |
|
| 32 |
Accelerate can also be installed with conda with: |
| 33 |
|
| 34 |
```bash |
| 35 |
conda install -c conda-forge accelerate |
| 36 |
``` |
| 37 |
|
| 38 |
## Source |
| 39 |
|
| 40 |
New features are added every day that haven't been released yet. To try them out yourself, install |
| 41 |
from the GitHub repository: |
| 42 |
|
| 43 |
```bash |
| 44 |
pip install git+https://github.com/huggingface/accelerate |
| 45 |
``` |
| 46 |
|
| 47 |
If you're working on contributing to the library or wish to play with the source code and see live |
| 48 |
results as you run the code, an editable version can be installed from a locally-cloned version of the |
| 49 |
repository: |
| 50 |
|
| 51 |
```bash |
| 52 |
git clone https://github.com/huggingface/accelerate |
| 53 |
cd accelerate |
| 54 |
pip install -e . |
| 55 |
``` |
| 56 |
|
| 57 |
## Configuration |
| 58 |
|
| 59 |
After installing, you need to configure Accelerate for how the current system is set up for training. |
| 60 |
To do so run the following and answer the questions prompted to you: |
| 61 |
|
| 62 |
```bash |
| 63 |
accelerate config |
| 64 |
``` |
| 65 |
|
| 66 |
To write a barebones configuration that doesn't include options such as DeepSpeed configuration or running on TPUs, you can quickly run: |
| 67 |
|
| 68 |
```bash |
| 69 |
python -c "from accelerate.utils import write_basic_config; write_basic_config(mixed_precision='fp16')" |
| 70 |
``` |
| 71 |
|
| 72 |
Accelerate will automatically utilize the maximum number of GPUs available and set the mixed precision mode. |
| 73 |
|
| 74 |
To check that your configuration looks fine, run: |
| 75 |
|
| 76 |
```bash |
| 77 |
accelerate env |
| 78 |
``` |
| 79 |
|
| 80 |
An example output is shown below, which describes two GPUs on a single machine with no mixed precision being used: |
| 81 |
|
| 82 |
|
| 83 |
```bash |
| 84 |
- `Accelerate` version: 1.2.0.dev0 |
| 85 |
- Platform: Linux-6.8.0-47-generic-x86_64-with-glibc2.35 |
| 86 |
- `accelerate` bash location: /home/zach/miniconda3/envs/accelerate/bin/accelerate |
| 87 |
- Python version: 3.10.13 |
| 88 |
- Numpy version: 1.26.4 |
| 89 |
- PyTorch version (GPU?): 2.5.1+cu124 (True) |
| 90 |
- PyTorch XPU available: False |
| 91 |
- PyTorch NPU available: False |
| 92 |
- PyTorch MLU available: False |
| 93 |
- PyTorch MUSA available: False |
| 94 |
- System RAM: 187.91 GB |
| 95 |
- GPU type: NVIDIA GeForce RTX 4090 |
| 96 |
- `Accelerate` default config: |
| 97 |
- compute_environment: LOCAL_MACHINE |
| 98 |
- distributed_type: MULTI_GPU |
| 99 |
- mixed_precision: no |
| 100 |
- use_cpu: False |
| 101 |
- debug: False |
| 102 |
- num_processes: 2 |
| 103 |
- machine_rank: 0 |
| 104 |
- num_machines: 1 |
| 105 |
- gpu_ids: all |
| 106 |
- rdzv_backend: static |
| 107 |
- same_network: True |
| 108 |
- main_training_function: main |
| 109 |
- enable_cpu_affinity: False |
| 110 |
- downcast_bf16: no |
| 111 |
- tpu_use_cluster: False |
| 112 |
- tpu_use_sudo: False |
| 113 |
- tpu_env: [] |
| 114 |
``` |