huggingface / diffusers

🤗 Diffusers: State-of-the-art diffusion models for image and audio generation in PyTorch and FLAX.
https://huggingface.co/docs/diffusers
Apache License 2.0
25.27k stars 5.23k forks source link

operator torchvision::nms does not exist #9109

Open andysingal opened 1 month ago

andysingal commented 1 month ago

Describe the bug

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/transformers/utils/import_utils.py](https://localhost:8080/#) in _get_module(self, module_name)
   1602         try:
-> 1603             return importlib.import_module("." + module_name, self.__name__)
   1604         except Exception as e:

54 frames
RuntimeError: operator torchvision::nms does not exist

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
RuntimeError: Failed to import transformers.models.auto.image_processing_auto because of the following error (look up to see its traceback):
operator torchvision::nms does not exist

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
RuntimeError: Failed to import diffusers.loaders.single_file_model because of the following error (look up to see its traceback):
Failed to import transformers.models.auto.image_processing_auto because of the following error (look up to see its traceback):
operator torchvision::nms does not exist

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/diffusers/utils/import_utils.py](https://localhost:8080/#) in _get_module(self, module_name)
    808             return importlib.import_module("." + module_name, self.__name__)
    809         except Exception as e:
--> 810             raise RuntimeError(
    811                 f"Failed to import {self.__name__}.{module_name} because of the following error (look up to see its"
    812                 f" traceback):\n{e}"

RuntimeError: Failed to import diffusers.models.transformers.pixart_transformer_2d because of the following error (look up to see its traceback):
Failed to import diffusers.loaders.single_file_model because of the following error (look up to see its traceback):
Failed to import transformers.models.auto.image_processing_auto because of the following error (look up to see its traceback):
operator torchvision::nms does not exist

Reproduction

pip install diffusers transformers datasets optimum-quanto -qU

from optimum.quanto import freeze, qfloat8, quantize
from diffusers import PixArtSigmaPipeline
import torch

pipeline = PixArtSigmaPipeline.from_pretrained(
    "PixArt-alpha/PixArt-Sigma-XL-2-1024-MS", torch_dtype=torch.float16
).to("cuda")

quantize(pipeline.transformer, weights=qfloat8)
freeze(pipeline.transformer)

image = pipeline("ghibli style, a fantasy landscape with castles").images[0]

Logs

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/transformers/utils/import_utils.py in _get_module(self, module_name)
   1602         try:
-> 1603             return importlib.import_module("." + module_name, self.__name__)
   1604         except Exception as e:

54 frames
RuntimeError: operator torchvision::nms does not exist

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
RuntimeError: Failed to import transformers.models.auto.image_processing_auto because of the following error (look up to see its traceback):
operator torchvision::nms does not exist

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
RuntimeError: Failed to import diffusers.loaders.single_file_model because of the following error (look up to see its traceback):
Failed to import transformers.models.auto.image_processing_auto because of the following error (look up to see its traceback):
operator torchvision::nms does not exist

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/diffusers/utils/import_utils.py in _get_module(self, module_name)
    808             return importlib.import_module("." + module_name, self.__name__)
    809         except Exception as e:
--> 810             raise RuntimeError(
    811                 f"Failed to import {self.__name__}.{module_name} because of the following error (look up to see its"
    812                 f" traceback):\n{e}"

RuntimeError: Failed to import diffusers.models.transformers.pixart_transformer_2d because of the following error (look up to see its traceback):
Failed to import diffusers.loaders.single_file_model because of the following error (look up to see its traceback):
Failed to import transformers.models.auto.image_processing_auto because of the following error (look up to see its traceback):
operator torchvision::nms does not exist

### System Info

Copy-and-paste the text below in your GitHub issue and FILL OUT the two last points.



### Who can help?

@sayakpaul  @yiyixuxu  @asomoza  
wendashi commented 3 weeks ago

I meet the similar situation, tried various methods and ultimately, I uninstall torch (which is installed by pip), then pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118, it works out😂

asomoza commented 3 weeks ago

Hi, is this issue resolved now then?