huggingface / huggingface/diffusers

`StableDiffusionPipeline` produces `nans` for SD2.1 (Mac, cpu device)

オープン
#6,136 コメント 15 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug contributions-welcome help wanted stale
主要言語
Python
スター
34.5k
フォーク
7.3k
平均マージ
3日 3時間
マージ済み PR(30日)
91

説明

### Describe the bug

`StableDiffusionPipeline` produces `nans` for SD2.1.

![CleanShot 2023-12-11 at 14 27 56@2x](https://github.com/huggingface/diffusers/assets/40663591/112c80e5-7e62-4e40-a0df-4881a04b1297)

The issue seems to be in the `pipe.unet.conv_in`. Printing the mean / std for `sample` before and after `conv_in` gives:
```
m,s = tensor(0.005) tensor(0.996)
m,s = tensor(15962061100191580160., grad_fn=) tensor(16510648845702789070848., grad_fn=)
```

### Reproduction

Make sure I'm using the latest official diffusers version
```
# uninstall local, editable version
!pip uninstall diffusers -y -qq
# install official version
!pip install diffusers -qq
# restart notebook now
```

Code to reproduce
```
from diffusers import StableDiffusionPipeline
pipe = StableDiffusionPipeline.from_pretrained('stabilityai/stable-diffusion-2-1')
result = pipe('the sun', output_type='pt')
result.images[0]
```

Output:
```
tensor([[[nan, nan, nan, ..., nan, nan, nan],
[nan, nan, nan, ..., nan, nan, nan],
[nan, nan, nan, ..., nan, nan, nan],
...
```

### Logs

_No response_

### System Info

- `diffusers` version: 0.24.0
- Platform: macOS-14.1.2-arm64-arm-64bit
- Python version: 3.11.6
- PyTorch version (GPU?): 2.1.1 (False)
- Huggingface_hub version: 0.19.4
- Transformers version: 4.35.2
- Accelerate version: 0.25.0
- xFormers version: not installed
- Using GPU in script?: no
- Using distributed or parallel set-up in script?: no

### Who can help?

Questions on pipelines > Stable Diffusion: @yiyixuxu @DN6 @sayakpaul @patrickvonplaten

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Run the supplied StableDiffusionPipeline reproduction with SD2.1 on the reported macOS CPU environment and confirm where NaNs first appear. Start at pipe.unet.conv_in and trace the sample before and after that entry point; done means the pipeline produces finite output tensors instead of NaNs.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python, pytorch
領域
ai, machine-learning
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。