-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When using diffusers with pytorch 2.4.0, there is an error on import
Reproduction
Install diffusers and then instantiate StableVideoDiffusionXL
from diffusers import StableVideoDiffusionPipeline
import torch
from diffusers import StableVideoDiffusionPipeline
import PIL.Image
import random
from typing import List
from diffusers.utils import load_image, export_to_video
from hosted.utils.generic_runner import config
model: StableVideoDiffusionPipeline | None = None
MODEL = "weights/stable-video-diffusion-img2vid-xt-1-1"
HEIGHT = 768
WIDTH = 768
INPUT_IMAGE = "https://assets.weights.gg/rocket.png"
def main():
# start model
model = StableVideoDiffusionPipeline.from_pretrained(MODEL, torch_dtype=torch.float16, variant="fp16").to(
config.device
)
backend = "torch_tensorrt"
model.unet = torch.compile(
model.unet,
backend=backend,
options={
"truncate_long_and_double": True,
"enabled_precisions": {torch.float32, torch.float16},
},
dynamic=False,
)
input_image_url = INPUT_IMAGE
image = load_image(input_image_url)
image = image.resize((WIDTH, HEIGHT))
# Ensure using the same inference steps as the loaded model and CFG set to 0.
# get random seed
seed = random.randint(0, (2**32) - 1)
generator = torch.manual_seed(seed)
frames: List[PIL.Image.Image] = model(
image,
height=HEIGHT,
width=WIDTH,
num_frames=25,
num_inference_steps=25,
generator=generator,
motion_bucket_id=127,
).frames[0]
if frames is None or len(frames) == 0:
print("Failed to generate image")
return None
# For each image, resize back
mirrored_frames = frames[::-1]
frames = frames + mirrored_frames
output_video = export_to_video(frames, "generated_video.mp4", fps=14)
print(output_video)
if __name__ == "__main__":
main()Logs
2024-07-24T23:42:57.499313371Z stderr F File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
2024-07-24T23:42:57.499408839Z stderr F return _bootstrap._gcd_import(name[level:], package, level)
2024-07-24T23:42:57.499453974Z stderr F ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-07-24T23:42:57.499465906Z stderr F File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
2024-07-24T23:42:57.499482808Z stderr F File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
2024-07-24T23:42:57.49951041Z stderr F File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
2024-07-24T23:42:57.499538853Z stderr F File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
2024-07-24T23:42:57.499553601Z stderr F File "<frozen importlib._bootstrap_external>", line 940, in exec_module
2024-07-24T23:42:57.499560053Z stderr F File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
2024-07-24T23:42:57.499566385Z stderr F File "/usr/local/lib/python3.11/site-packages/transformers/models/clip/image_processing_clip.py", line 21, in <module>
2024-07-24T23:42:57.499582625Z stderr F from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
2024-07-24T23:42:57.499594177Z stderr F File "/usr/local/lib/python3.11/site-packages/transformers/image_processing_utils.py", line 21, in <module>
2024-07-24T23:42:57.499647747Z stderr F from .image_transforms import center_crop, normalize, rescale
2024-07-24T23:42:57.499668376Z stderr F File "/usr/local/lib/python3.11/site-packages/transformers/image_transforms.py", line 22, in <module>
2024-07-24T23:42:57.499728719Z stderr F from .image_utils import (
2024-07-24T23:42:57.499742746Z stderr F File "/usr/local/lib/python3.11/site-packages/transformers/image_utils.py", line 58, in <module>
2024-07-24T23:42:57.499790325Z stderr F from torchvision.transforms import InterpolationMode
2024-07-24T23:42:57.499802387Z stderr F File "/usr/local/lib/python3.11/site-packages/torchvision/__init__.py", line 10, in <module>
2024-07-24T23:42:57.499857801Z stderr F from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils # usort:skip
2024-07-24T23:42:57.499977546Z stderr F ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-07-24T23:42:57.499994408Z stderr F File "/usr/local/lib/python3.11/site-packages/torchvision/_meta_registrations.py", line 163, in <module>
2024-07-24T23:42:57.500078526Z stderr F @torch.library.register_fake("torchvision::nms")
2024-07-24T23:42:57.50011302Z stderr F ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-07-24T23:42:57.50014487Z stderr F AttributeError: module 'torch.library' has no attribute 'register_fake'
2024-07-24T23:42:57.500154999Z stderr F
2024-07-24T23:42:57.500160569Z stderr F The above exception was the direct cause of the following exception:
2024-07-24T23:42:57.50016599Z stderr F
2024-07-24T23:42:57.50017134Z stderr F Traceback (most recent call last):
2024-07-24T23:42:57.500189193Z stderr F File "/usr/local/lib/python3.11/site-packages/diffusers/utils/import_utils.py", line 808, in _get_module
2024-07-24T23:42:57.500358596Z stderr F return importlib.import_module("." + module_name, self.__name__)
2024-07-24T23:42:57.500421955Z stderr F ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-07-24T23:42:57.500431673Z stderr F File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
2024-07-24T23:42:57.500524567Z stderr F return _bootstrap._gcd_import(name[level:], package, level)
2024-07-24T23:42:57.500605699Z stderr F ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-07-24T23:42:57.500643731Z stderr F File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
2024-07-24T23:42:57.500653389Z stderr F File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
2024-07-24T23:42:57.50065909Z stderr F File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
2024-07-24T23:42:57.500664409Z stderr F File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
2024-07-24T23:42:57.500668517Z stderr F File "<frozen importlib._bootstrap_external>", line 940, in exec_module
2024-07-24T23:42:57.500672545Z stderr F File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
2024-07-24T23:42:57.500677103Z stderr F File "/usr/local/lib/python3.11/site-packages/diffusers/pipelines/stable_video_diffusion/pipeline_stable_video_diffusion.py", line 22, in <module>
2024-07-24T23:42:57.500725404Z stderr F from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection
2024-07-24T23:42:57.500736024Z stderr F File "<frozen importlib._bootstrap>", line 1229, in _handle_fromlist
2024-07-24T23:42:57.500740683Z stderr F File "/usr/local/lib/python3.11/site-packages/transformers/utils/import_utils.py", line 1577, in __getattr__
2024-07-24T23:42:57.500998571Z stderr F value = getattr(module, name)
2024-07-24T23:42:57.501037664Z stderr F ^^^^^^^^^^^^^^^^^^^^^
2024-07-24T23:42:57.501049557Z stderr F File "/usr/local/lib/python3.11/site-packages/transformers/utils/import_utils.py", line 1576, in __getattr__
2024-07-24T23:42:57.501307986Z stderr F module = self._get_module(self._class_to_module[name])
2024-07-24T23:42:57.501382962Z stderr F ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-07-24T23:42:57.501397609Z stderr F File "/usr/local/lib/python3.11/site-packages/transformers/utils/import_utils.py", line 1588, in _get_module
2024-07-24T23:42:57.501653359Z stderr F raise RuntimeError(
2024-07-24T23:42:57.501663648Z stderr F RuntimeError: Failed to import transformers.models.clip.image_processing_clip because of the following error (look up to see its traceback):
2024-07-24T23:42:57.501668337Z stderr F module 'torch.library' has no attribute 'register_fake'
2024-07-24T23:42:57.501672374Z stderr F
2024-07-24T23:42:57.501676592Z stderr F The above exception was the direct cause of the following exception:
2024-07-24T23:42:57.501681211Z stderr F
2024-07-24T23:42:57.50168573Z stderr F Traceback (most recent call last):
2024-07-24T23:42:57.501697832Z stderr F File "<frozen runpy>", line 198, in _run_module_as_main
2024-07-24T23:42:57.501707761Z stderr F File "<frozen runpy>", line 88, in _run_code
2024-07-24T23:42:57.501711939Z stderr F File "/app/hosted/video/video_job_runner.py", line 22, in <module>
2024-07-24T23:42:57.501748622Z stderr F from diffusers import StableVideoDiffusionPipeline
2024-07-24T23:42:57.501766326Z stderr F File "<frozen importlib._bootstrap>", line 1229, in _handle_fromlist
2024-07-24T23:42:57.501784349Z stderr F File "/usr/local/lib/python3.11/site-packages/diffusers/utils/import_utils.py", line 799, in __getattr__
2024-07-24T23:42:57.501909549Z stderr F value = getattr(module, name)
2024-07-24T23:42:57.50194177Z stderr F ^^^^^^^^^^^^^^^^^^^^^
2024-07-24T23:42:57.501966105Z stderr F File "/usr/local/lib/python3.11/site-packages/diffusers/utils/import_utils.py", line 799, in __getattr__
2024-07-24T23:42:57.502117549Z stderr F value = getattr(module, name)
2024-07-24T23:42:57.502151608Z stderr F ^^^^^^^^^^^^^^^^^^^^^
2024-07-24T23:42:57.502164081Z stderr F File "/usr/local/lib/python3.11/site-packages/diffusers/utils/import_utils.py", line 798, in __getattr__
2024-07-24T23:42:57.502358266Z stderr F module = self._get_module(self._class_to_module[name])
2024-07-24T23:42:57.502422437Z stderr F ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-07-24T23:42:57.502466269Z stderr F File "/usr/local/lib/python3.11/site-packages/diffusers/utils/import_utils.py", line 810, in _get_module
2024-07-24T23:42:57.502615108Z stderr F raise RuntimeError(
2024-07-24T23:42:57.502624215Z stderr F RuntimeError: Failed to import diffusers.pipelines.stable_video_diffusion.pipeline_stable_video_diffusion because of the following error (look up to see its traceback):
2024-07-24T23:42:57.502629545Z stderr F Failed to import transformers.models.clip.image_processing_clip because of the following error (look up to see its traceback):
2024-07-24T23:42:57.502633873Z stderr F module 'torch.library' has no attribute 'register_fake'System Info
Copy-and-paste the text below in your GitHub issue and FILL OUT the two last points.
- 🤗 Diffusers version: 0.29.2
- Platform: Linux-5.15.0-1067-azure-x86_64-with-glibc2.36
- Running on a notebook?: No
- Running on Google Colab?: No
- Python version: 3.11.8
- PyTorch version (GPU?): 2.4.0+cu121 (True)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Huggingface_hub version: 0.23.4
- Transformers version: 4.42.4
- Accelerate version: 0.32.1
- PEFT version: not installed
- Bitsandbytes version: not installed
- Safetensors version: 0.4.3
- xFormers version: 0.0.27
- Accelerator: NVIDIA A100 80GB PCIe, 81920 MiB VRAM
Who can help?
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working