installation.md 4.83 KB
Newer Older
Patrick von Platen's avatar
Patrick von Platen committed
1
<!--Copyright 2023 The HuggingFace Team. All rights reserved.
Nathan Lambert's avatar
Nathan Lambert committed
2
3
4
5
6
7
8
9
10
11
12

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-->

13
# Installation
Patrick von Platen's avatar
Patrick von Platen committed
14

15
Install 🤗 Diffusers for whichever deep learning library you're working with.
Patrick von Platen's avatar
Patrick von Platen committed
16

17
🤗 Diffusers is tested on Python 3.7+, PyTorch 1.7.0+ and Flax. Follow the installation instructions below for the deep learning library you are using:
18
19
20

- [PyTorch](https://pytorch.org/get-started/locally/) installation instructions.
- [Flax](https://flax.readthedocs.io/en/latest/) installation instructions.
Patrick von Platen's avatar
Patrick von Platen committed
21

22
## Install with pip
Patrick von Platen's avatar
Patrick von Platen committed
23

24
25
You should install 🤗 Diffusers in a [virtual environment](https://docs.python.org/3/library/venv.html).
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/).
26
A virtual environment makes it easier to manage different projects and avoid compatibility issues between dependencies.
27
28
29
30
31
32
33
34
35
36
37

Start by creating a virtual environment in your project directory:

```bash
python -m venv .env
```

Activate the virtual environment:

```bash
source .env/bin/activate
Patrick von Platen's avatar
Patrick von Platen committed
38
```
39

40
🤗 Diffusers also relies on the 🤗 Transformers library, and you can install both with the following command:
41

42
43
<frameworkcontent>
<pt>
44
```bash
45
pip install diffusers["torch"] transformers
46
```
47
48
</pt>
<jax>
49
```bash
50
pip install diffusers["flax"] transformers
Patrick von Platen's avatar
Patrick von Platen committed
51
```
52
53
</jax>
</frameworkcontent>
Patrick von Platen's avatar
Patrick von Platen committed
54

55
56
## Install from source

57
Before installing 🤗 Diffusers from source, make sure you have `torch` and 🤗 Accelerate installed.
58

59
For `torch` installation, refer to the `torch` [installation](https://pytorch.org/get-started/locally/#start-locally) guide.
60

61
To install 🤗 Accelerate:
62
63
64
65
66

```bash
pip install accelerate
```

67
68
69
70
71
72
73
74
75
76
77
Install 🤗 Diffusers from source with the following command:

```bash
pip install git+https://github.com/huggingface/diffusers
```

This command installs the bleeding edge `main` version rather than the latest `stable` version.
The `main` version is useful for staying up-to-date with the latest developments.
For instance, if a bug has been fixed since the last official release but a new release hasn't been rolled out yet.
However, this means the `main` version may not always be stable.
We strive to keep the `main` version operational, and most issues are usually resolved within a few hours or a day.
78
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!
79
80
81
82
83
84
85
86
87
88
89
90

## Editable install

You will need an editable install if you'd like to:

* Use the `main` version of the source code.
* Contribute to 🤗 Diffusers and need to test changes in the code.

Clone the repository and install 🤗 Diffusers with the following commands:

```bash
git clone https://github.com/huggingface/diffusers.git
Partho's avatar
Partho committed
91
cd diffusers
92
93
```

94
95
96
<frameworkcontent>
<pt>
```bash
97
98
pip install -e ".[torch]"
```
99
100
101
</pt>
<jax>
```bash
102
pip install -e ".[flax]"
103
```
104
105
</jax>
</frameworkcontent>
106
107
108

These commands will link the folder you cloned the repository to and your Python library paths.
Python will now look inside the folder you cloned to in addition to the normal library paths.
109
For example, if your Python packages are typically installed in `~/anaconda3/envs/main/lib/python3.7/site-packages/`, Python will also search the `~/diffusers/` folder you cloned to.
Patrick von Platen's avatar
Patrick von Platen committed
110

111
<Tip warning={true}>
Patrick von Platen's avatar
Patrick von Platen committed
112

113
You must keep the `diffusers` folder if you want to keep using the library.
Patrick von Platen's avatar
Patrick von Platen committed
114

115
</Tip>
Patrick von Platen's avatar
Patrick von Platen committed
116

117
118
119
120
121
122
Now you can easily update your clone to the latest version of 🤗 Diffusers with the following command:

```bash
cd ~/diffusers/
git pull
```
Patrick von Platen's avatar
Patrick von Platen committed
123

124
Your Python environment will find the `main` version of 🤗 Diffusers on the next run.
125
126
127
128
129

## Notice on telemetry logging

Our library gathers telemetry information during `from_pretrained()` requests.
This data includes the version of Diffusers and PyTorch/Flax, the requested model or pipeline class,
130
and the path to a pre-trained checkpoint if it is hosted on the Hub.
131
This usage data helps us debug issues and prioritize new features.
132
133
Telemetry is only sent when loading models and pipelines from the HuggingFace Hub,
and is not collected during local usage.
134
135
136
137
138
139
140
141
142
143
144
145

We understand that not everyone wants to share additional information, and we respect your privacy,
so you can disable telemetry collection by setting the `DISABLE_TELEMETRY` environment variable from your terminal:

On Linux/MacOS:
```bash
export DISABLE_TELEMETRY=YES
```

On Windows:
```bash
set DISABLE_TELEMETRY=YES
146
```