facebookincubator / AITemplate

AITemplate is a Python framework which renders neural network into high performance CUDA/HIP C++ code. Specialized for FP16 TensorCore (NVIDIA GPU) and MatrixCore (AMD GPU) inference.
Apache License 2.0
4.56k stars 370 forks source link

Cannot compile Stable Diffusion #127

Open donglinz opened 1 year ago

donglinz commented 1 year ago

Hi,

I am trying the stable diffusion in the example https://github.com/facebookincubator/AITemplate/tree/main/examples/05_stable_diffusion

But get the following error when compiling the model with python3 examples/05_stable_diffusion/compile.py --token ACCESS_TOKEN

File "examples/05_stable_diffusion/compile.py", line 379, in <module>
    compile_diffusers()
  File "/home/xxx/.conda/envs/ait/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/xxx/.conda/envs/ait/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/xxx/.conda/envs/ait/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/xxx/.conda/envs/ait/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "examples/05_stable_diffusion/compile.py", line 342, in compile_diffusers
    pipe = StableDiffusionPipeline.from_pretrained(
  File "/home/xxx/.conda/envs/ait/lib/python3.8/site-packages/diffusers/pipeline_utils.py", line 325, in from_pretrained
    is_pipeline_module = hasattr(pipelines, library_name)

package version: pytorch==1.12.1+cu116, transformers==4.21.2, diffusers==0.3.0, click==8.1.3. AIT is using latest version from main branch, commit: bbc311bc01014ba7084cd3f9309b35402b721b3c

MARD1NO commented 1 year ago

Hi,

I am trying the stable diffusion in the example https://github.com/facebookincubator/AITemplate/tree/main/examples/05_stable_diffusion

But get the following error when compiling the model with python3 examples/05_stable_diffusion/compile.py --token ACCESS_TOKEN

File "examples/05_stable_diffusion/compile.py", line 379, in <module>
    compile_diffusers()
  File "/home/xxx/.conda/envs/ait/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/xxx/.conda/envs/ait/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/xxx/.conda/envs/ait/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/xxx/.conda/envs/ait/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "examples/05_stable_diffusion/compile.py", line 342, in compile_diffusers
    pipe = StableDiffusionPipeline.from_pretrained(
  File "/home/xxx/.conda/envs/ait/lib/python3.8/site-packages/diffusers/pipeline_utils.py", line 325, in from_pretrained
    is_pipeline_module = hasattr(pipelines, library_name)

package version: pytorch==1.12.1+cu116, transformers==4.21.2, diffusers==0.3.0, click==8.1.3. AIT is using latest version from main branch, commit: bbc311b

Also meet the same problem,try to pip install the newest diffusers == 0.11.1

terrychenism commented 1 year ago

seems this PR https://github.com/facebookincubator/AITemplate/pull/126 breaks SD example.

donglinz commented 1 year ago

@terrychenism maybe not, https://github.com/facebookincubator/AITemplate/pull/126 is later than the commit I used.

terrychenism commented 1 year ago

Can you try this commit 8c158f54278975a074f9cadf12982bcba259436d, it works well on my side.

donglinz commented 1 year ago

@terrychenism Thank you!

78Alpha commented 1 year ago

Can you try this commit 8c158f5, it works well on my side.

Tried out yours after the current master and all other versions failed to compile. This one throws TypeError: hasattr(): attribute name must be string

MARD1NO commented 1 year ago

Can you try this commit 8c158f5, it works well on my side.

Tried out yours after the current master and all other versions failed to compile. This one throws TypeError: hasattr(): attribute name must be string

maybe you need to use python3.8

78Alpha commented 1 year ago

Can you try this commit 8c158f5, it works well on my side.

Tried out yours after the current master and all other versions failed to compile. This one throws TypeError: hasattr(): attribute name must be string

maybe you need to use python3.8

Using 3.8.10 from the Docker. Updated from diffusers 0.3.0 to 0.4.0 and ended up getting a flip flop between

File "/usr/local/lib/python3.8/dist-packages/diffusers/models/unet_blocks.py", line 510, in __init__ out_channels // attn_num_head_channels, TypeError: unsupported operand type(s) for //: 'int' and 'list'

and

File "/usr/local/lib/python3.8/dist-packages/diffusers/pipeline_utils.py", line 404, in from_pretrained if class_name.startswith("Flax"): AttributeError: 'NoneType' object has no attribute 'startswith'