Skip to content

Commit 7ea065c

Browse files
authored
[docs] Install (#12026)
* initial * init
1 parent 7a7a487 commit 7ea065c

File tree

1 file changed

+73
-100
lines changed

1 file changed

+73
-100
lines changed

docs/source/en/installation.md

Lines changed: 73 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -12,183 +12,156 @@ specific language governing permissions and limitations under the License.
1212

1313
# Installation
1414

15-
🤗 Diffusers is tested on Python 3.8+, PyTorch 1.7.0+, and Flax. Follow the installation instructions below for the deep learning library you are using:
15+
Diffusers is tested on Python 3.8+, PyTorch 1.4+, and Flax 0.4.1+. Follow the installation instructions for the deep learning library you're using, [PyTorch](https://pytorch.org/get-started/locally/) or [Flax](https://flax.readthedocs.io/en/latest/).
1616

17-
- [PyTorch](https://pytorch.org/get-started/locally/) installation instructions
18-
- [Flax](https://flax.readthedocs.io/en/latest/) installation instructions
19-
20-
## Install with pip
21-
22-
You should install 🤗 Diffusers in a [virtual environment](https://docs.python.org/3/library/venv.html).
23-
If you're unfamiliar with Python virtual environments, take a look at this [guide](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/).
24-
A virtual environment makes it easier to manage different projects and avoid compatibility issues between dependencies.
25-
26-
Create a virtual environment with Python or [uv](https://docs.astral.sh/uv/) (refer to [Installation](https://docs.astral.sh/uv/getting-started/installation/) for installation instructions), a fast Rust-based Python package and project manager.
27-
28-
<hfoptions id="install">
29-
<hfoption id="uv">
17+
Create a [virtual environment](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/) for easier management of separate projects and to avoid compatibility issues between dependencies. Use [uv](https://docs.astral.sh/uv/), a Rust-based Python package and project manager, to create a virtual environment and install Diffusers.
3018

3119
```bash
3220
uv venv my-env
3321
source my-env/bin/activate
3422
```
3523

36-
</hfoption>
37-
<hfoption id="Python">
38-
39-
```bash
40-
python -m venv my-env
41-
source my-env/bin/activate
42-
```
43-
44-
</hfoption>
45-
</hfoptions>
46-
47-
You should also install 🤗 Transformers because 🤗 Diffusers relies on its models.
48-
24+
Install Diffusers with one of the following methods.
4925

50-
<frameworkcontent>
51-
<pt>
52-
53-
PyTorch only supports Python 3.8 - 3.11 on Windows. Install Diffusers with uv.
54-
55-
```bash
56-
uv install diffusers["torch"] transformers
57-
```
26+
<hfoptions id="install">
27+
<hfoption id="pip">
5828

59-
You can also install Diffusers with pip.
29+
PyTorch only supports Python 3.8 - 3.11 on Windows.
6030

6131
```bash
62-
pip install diffusers["torch"] transformers
32+
uv pip install diffusers["torch"] transformers
6333
```
6434

65-
</pt>
66-
<jax>
67-
68-
Install Diffusers with uv.
35+
Use the command below for Flax.
6936

7037
```bash
7138
uv pip install diffusers["flax"] transformers
7239
```
7340

74-
You can also install Diffusers with pip.
75-
76-
```bash
77-
pip install diffusers["flax"] transformers
78-
```
79-
80-
</jax>
81-
</frameworkcontent>
82-
83-
## Install with conda
84-
85-
After activating your virtual environment, with `conda` (maintained by the community):
41+
</hfoption>
42+
<hfoption id="conda">
8643

8744
```bash
8845
conda install -c conda-forge diffusers
8946
```
9047

91-
## Install from source
48+
</hfoption>
49+
<hfoption id="source">
9250

93-
Before installing 🤗 Diffusers from source, make sure you have PyTorch and 🤗 Accelerate installed.
51+
A source install installs the `main` version instead of the latest `stable` version. The `main` version is useful for staying updated with the latest changes but it may not always be stable. If you run into a problem, open an [Issue](https://github.com/huggingface/diffusers/issues/new/choose) and we will try to resolve it as soon as possible.
9452

95-
To install 🤗 Accelerate:
53+
Make sure [Accelerate](https://huggingface.co/docs/accelerate/index) is installed.
9654

9755
```bash
98-
pip install accelerate
56+
uv pip install accelerate
9957
```
10058

101-
Then install 🤗 Diffusers from source:
59+
Install Diffusers from source with the command below.
10260

10361
```bash
104-
pip install git+https://github.com/huggingface/diffusers
62+
uv pip install git+https://github.com/huggingface/diffusers
10563
```
10664

107-
This command installs the bleeding edge `main` version rather than the latest `stable` version.
108-
The `main` version is useful for staying up-to-date with the latest developments.
109-
For instance, if a bug has been fixed since the last official release but a new release hasn't been rolled out yet.
110-
However, this means the `main` version may not always be stable.
111-
We strive to keep the `main` version operational, and most issues are usually resolved within a few hours or a day.
112-
If you run into a problem, please open an [Issue](https://github.com/huggingface/diffusers/issues/new/choose) so we can fix it even sooner!
65+
</hfoption>
66+
</hfoptions>
11367

11468
## Editable install
11569

116-
You will need an editable install if you'd like to:
70+
An editable install is recommended for development workflows or if you're using the `main` version of the source code. A special link is created between the cloned repository and the Python library paths. This avoids reinstalling a package after every change.
11771

118-
* Use the `main` version of the source code.
119-
* Contribute to 🤗 Diffusers and need to test changes in the code.
72+
Clone the repository and install Diffusers with the following commands.
12073

121-
Clone the repository and install 🤗 Diffusers with the following commands:
74+
<hfoptions id="editable">
75+
<hfoption id="PyTorch">
12276

12377
```bash
12478
git clone https://github.com/huggingface/diffusers.git
12579
cd diffusers
80+
uv pip install -e ".[torch]"
12681
```
12782

128-
<frameworkcontent>
129-
<pt>
130-
```bash
131-
pip install -e ".[torch]"
132-
```
133-
</pt>
134-
<jax>
83+
</hfoption>
84+
<hfoption id="Flax">
85+
13586
```bash
136-
pip install -e ".[flax]"
87+
git clone https://github.com/huggingface/diffusers.git
88+
cd diffusers
89+
uv pip install -e ".[flax]"
13790
```
138-
</jax>
139-
</frameworkcontent>
140-
141-
These commands will link the folder you cloned the repository to and your Python library paths.
142-
Python will now look inside the folder you cloned to in addition to the normal library paths.
143-
For example, if your Python packages are typically installed in `~/anaconda3/envs/main/lib/python3.10/site-packages/`, Python will also search the `~/diffusers/` folder you cloned to.
14491

145-
<Tip warning={true}>
146-
147-
You must keep the `diffusers` folder if you want to keep using the library.
92+
</hfoption>
93+
</hfoptions>
14894

149-
</Tip>
95+
> [!WARNING]
96+
> You must keep the `diffusers` folder if you want to keep using the library with the editable install.
15097
151-
Now you can easily update your clone to the latest version of 🤗 Diffusers with the following command:
98+
Update your cloned repository to the latest version of Diffusers with the command below.
15299

153100
```bash
154101
cd ~/diffusers/
155102
git pull
156103
```
157104

158-
Your Python environment will find the `main` version of 🤗 Diffusers on the next run.
159-
160105
## Cache
161106

162-
Model weights and files are downloaded from the Hub to a cache which is usually your home directory. You can change the cache location by specifying the `HF_HOME` or `HUGGINFACE_HUB_CACHE` environment variables or configuring the `cache_dir` parameter in methods like [`~DiffusionPipeline.from_pretrained`].
107+
Model weights and files are downloaded from the Hub to a cache, which is usually your home directory. Change the cache location with the [HF_HOME](https://huggingface.co/docs/huggingface_hub/package_reference/environment_variables#hfhome) or [HF_HUB_CACHE](https://huggingface.co/docs/huggingface_hub/package_reference/environment_variables#hfhubcache) environment variables or configuring the `cache_dir` parameter in methods like [`~DiffusionPipeline.from_pretrained`].
163108

164-
Cached files allow you to run 🤗 Diffusers offline. To prevent 🤗 Diffusers from connecting to the internet, set the `HF_HUB_OFFLINE` environment variable to `1` and 🤗 Diffusers will only load previously downloaded files in the cache.
109+
<hfoptions id="cache">
110+
<hfoption id="env variable">
111+
112+
```bash
113+
export HF_HOME="/path/to/your/cache"
114+
export HF_HUB_CACHE="/path/to/your/hub/cache"
115+
```
116+
117+
</hfoption>
118+
<hfoption id="from_pretrained">
119+
120+
```py
121+
from diffusers import DiffusionPipeline
122+
123+
pipeline = DiffusionPipeline.from_pretrained(
124+
"black-forest-labs/FLUX.1-dev",
125+
cache_dir="/path/to/your/cache"
126+
)
127+
```
128+
129+
</hfoption>
130+
</hfoptions>
131+
132+
Cached files allow you to use Diffusers offline. Set the [HF_HUB_OFFLINE](https://huggingface.co/docs/huggingface_hub/package_reference/environment_variables#hfhuboffline) environment variable to `1` to prevent Diffusers from connecting to the internet.
165133

166134
```shell
167135
export HF_HUB_OFFLINE=1
168136
```
169137

170-
For more details about managing and cleaning the cache, take a look at the [caching](https://huggingface.co/docs/huggingface_hub/guides/manage-cache) guide.
138+
For more details about managing and cleaning the cache, take a look at the [Understand caching](https://huggingface.co/docs/huggingface_hub/guides/manage-cache) guide.
171139

172140
## Telemetry logging
173141

174-
Our library gathers telemetry information during [`~DiffusionPipeline.from_pretrained`] requests.
175-
The data gathered includes the version of 🤗 Diffusers and PyTorch/Flax, the requested model or pipeline class,
176-
and the path to a pretrained checkpoint if it is hosted on the Hugging Face Hub.
142+
Diffusers gathers telemetry information during [`~DiffusionPipeline.from_pretrained`] requests.
143+
The data gathered includes the Diffusers and PyTorch/Flax version, the requested model or pipeline class,
144+
and the path to a pretrained checkpoint if it is hosted on the Hub.
145+
177146
This usage data helps us debug issues and prioritize new features.
178147
Telemetry is only sent when loading models and pipelines from the Hub,
179148
and it is not collected if you're loading local files.
180149

181-
We understand that not everyone wants to share additional information,and we respect your privacy.
182-
You can disable telemetry collection by setting the `HF_HUB_DISABLE_TELEMETRY` environment variable from your terminal:
150+
Opt-out and disable telemetry collection with the [HF_HUB_DISABLE_TELEMETRY](https://huggingface.co/docs/huggingface_hub/package_reference/environment_variables#hfhubdisabletelemetry) environment variable.
183151

184-
On Linux/MacOS:
152+
<hfoptions id="telemetry">
153+
<hfoption id="Linux/macOS">
185154

186155
```bash
187156
export HF_HUB_DISABLE_TELEMETRY=1
188157
```
189158

190-
On Windows:
159+
</hfoption>
160+
<hfoption id="Windows">
191161

192162
```bash
193163
set HF_HUB_DISABLE_TELEMETRY=1
194164
```
165+
166+
</hfoption>
167+
</hfoptions>

0 commit comments

Comments
 (0)