Skip to content

Commit e9ccc73

Browse files
committed
more examples
1 parent 407b67f commit e9ccc73

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/diffusers/models/modeling_utils.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,12 +837,18 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P
837837
>>> model = AutoModel.from_pretrained(
838838
... "stabilityai/stable-diffusion-xl-base-1.0", subfolder="unet", device_map="auto"
839839
... )
840+
>>> # Specifying a dictionary as `device_map` also works.
841+
>>> model = AutoModel.from_pretrained(
842+
... "stabilityai/stable-diffusion-xl-base-1.0",
843+
... subfolder="unet",
844+
... device_map={"": torch.device("cuda")},
845+
... )
840846
```
841847
842848
Set `device_map="auto"` to have 🤗 Accelerate automatically compute the most optimized `device_map`. For
843849
more information about each option see [designing a device
844-
map](https://hf.co/docs/accelerate/main/en/usage_guides/big_modeling#designing-a-device-map). You can
845-
also refer to the [Diffusers-specific
850+
map](https://huggingface.co/docs/accelerate/en/concept_guides/big_model_inference#the-devicemap). You
851+
can also refer to the [Diffusers-specific
846852
documentation](https://huggingface.co/docs/diffusers/main/en/training/distributed_inference#model-sharding)
847853
for more concrete examples.
848854
max_memory (`Dict`, *optional*):

0 commit comments

Comments
 (0)