G-U-N / AnimateLCM

[SIGGRAPH ASIA 2024 TCS] AnimateLCM: Computation-Efficient Personalized Style Video Generation without Personalized Video Data
https://animatelcm.github.io
MIT License
612 stars 45 forks source link

Not working on M1 #20

Closed yukiarimo closed 7 months ago

yukiarimo commented 7 months ago

Code:

import torch

from diffusers import StableVideoDiffusionPipeline
from diffusers.utils import load_image, export_to_video

pipe = StableVideoDiffusionPipeline.from_pretrained(
    "stabilityai/stable-video-diffusion-img2vid-xt", torch_dtype=torch.float16, variant="fp16"
)
pipe.enable_model_cpu_offload()

# Load the conditioning image
image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/svd/rocket.png")
image = image.resize((1024, 576))

generator = torch.manual_seed(42)
frames = pipe(image, decode_chunk_size=8, generator=generator).frames[0]

export_to_video(frames, "generated.mp4", fps=7)

Error:

Traceback (most recent call last):
  File "p.py", line 16, in <module>
    frames = pipe(image, decode_chunk_size=8, generator=generator).frames[0]
  File "/Users/yuki/anaconda3/envs/ai/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "/Users/yuki/anaconda3/envs/ai/lib/python3.8/site-packages/diffusers/pipelines/stable_video_diffusion/pipeline_stable_video_diffusion.py", line 441, in __call__
    image_embeddings = self._encode_image(image, device, num_videos_per_prompt, self.do_classifier_free_guidance)
  File "/Users/yuki/anaconda3/envs/ai/lib/python3.8/site-packages/diffusers/pipelines/stable_video_diffusion/pipeline_stable_video_diffusion.py", line 168, in _encode_image
    image = image.to(device=device, dtype=dtype)
  File "/Users/yuki/anaconda3/envs/ai/lib/python3.8/site-packages/torch/cuda/__init__.py", line 289, in _lazy_init
    raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled
G-U-N commented 7 months ago

Thanks for the interest. I am not very sure about issue, and the code was tested on nvida gpus on linux. For inference with Animate-LCM-SVD-xt, please see issue-12. Also I have upload a local gradio.