运行时
Run inference Stable Diffusion with MIGraphX
2023-09-05 17:43:53
198

Hello,

I tried to run infernece the last version of stable diffusion with MIGraphX from DCU Toolkit 23.04 (DCU Z100L).

For this purpose I converted to ONNX model with script https://github.com/huggingface/diffusers/blob/main/scripts/convert_stable_diffusion_checkpoint_to_onnx.py 
Command:

python stable2onnx.py --model_path "stabilityai/stable-diffusion-2-1-base" --output_path "stable_diffusion_2_1-base"

After that I call parse_onnx steb by step for each part of model:

text_encoder = migraphx.parse_onnx("stable_diffusion_2_1-base/text_encoder/model.onnx")
unet = migraphx.parse_onnx("stable_diffusion_2_1-base/unet/model.onnx")

text_encoder parsed and run succsessfully, but unet parsing get stucks in infininity loop.

Any recommendations how to workaround this problem?

全部评论(2)
只看楼主
网
网友5pBMXU
楼主
2楼

install requirements with pip:

```

certifi==2023.7.22

charset-normalizer==3.2.0

coloredlogs==15.0.1

diffusers==0.21.2

filelock==3.12.4

flatbuffers==23.5.26

fsspec==2023.9.1

huggingface-hub==0.17.2

humanfriendly==10.0

idna==3.4

importlib-metadata==6.8.0

mpmath==1.3.0

numpy==1.24.4

onnx==1.14.1

onnxconverter-common==1.14.0

onnxruntime==1.15.1

packaging==23.1

Pillow==10.0.1

protobuf==3.20.2

PyYAML==6.0.1

regex==2023.8.8

requests==2.31.0

safetensors==0.3.3

sympy==1.12

tokenizers==0.13.3

torch @ file:///home/rsandreev/torch-1.13.1%2Bgit55d300e.abi0.dtk2304-cp38-cp38-manylinux2014_x86_64.whl

tqdm==4.66.1

transformers==4.33.2

typing_extensions==4.8.0

urllib3==2.0.4

zipp==3.17.0

```

Download converter with wget:

```

wget https://raw.githubusercontent.com/Amblyopius/Stable-Diffusion-ONNX-FP16/main/conv_sd_to_onnx.py

```

Run converter with following command:

```

python conv_sd_to_onnx.py --model_path "stabilityai/stable-diffusion-2-1-base" --output_path "stable_diffusion_2_1-base-ext"

```

Ignore errors, because its about running the model in torch.

So, the final step:

```

migraphx-driver perf --gpu --onnx /path/to/workspace/stable_diffusion_2_1-base-ext/unet/model.onnx --input-dim @sample 1 4 64 64

```

It should stucks during unet model loading.
2023/9/19
Q
qianqing
1楼
can you give your model to us?
2023/9/18
没有更多内容了
--
楼主
Level.4
0 帖子
楼主热帖
暂无数据