Closed jonluca closed 2 months ago
Maybe you can try to comment this line @torch.library.register_fake("torchvision::nms")
in your file /usr/local/lib/python3.11/site-packages/torchvision/_meta_registrations.py
.
hi! can you try to upgrade torch and torchvision to the latest version?
I'm using 0.19.0 already - are you unable to repro?
This is our requirements.txt
PyYAML==6.0.1
accelerate==0.33.0
aioboto3==13.1.1
aiobotocore==2.13.1
aiohttp==3.9.5
audioread==3.0.1
bitarray==2.9.2
boto3==1.34.106
diffq==0.2.4
diffusers==0.29.2
einops-exts==0.0.4
einops==0.8.0
fastapi==0.111.1
ffmpeg-python==0.2.0
faiss-cpu
huggingface_hub==0.24.2
julius==0.2.7
librosa==0.10.2.post1
llvmlite==0.43.0
munch==4.0.0
ninja==1.11.1.1
mutagen==1.47.0
nltk==3.8.1
numba==0.60.0
numpy==1.26.4
omegaconf==2.3.0
onnx2torch==1.5.14
onnxruntime-gpu==1.18.0; sys_platform == 'win32'
onnxruntime==1.18.1; sys_platform != 'win32'
phonemizer==3.2.1
prisma @ git+https://github.com/jonluca/prisma-client-py@6d0a9746b84708cd0a21bdea6ac590ff38f49b70
psutil==6.0.0
pydantic==2.8.2
pydub==0.25.1
pyinstaller==6.9.0
python-dotenv==1.0.1
pytorch-lightning==2.3.3
pyworld==0.3.4
redis[hiredis]==5.0.7
regex==2024.5.15
sacrebleu==2.4.2
safetensors==0.4.3
samplerate==0.2.1
scipy==1.14.0
soundfile==0.12.1
spacy==3.7.5
torch==2.4.0
torchaudio==2.4.0
torchcrepe==0.0.23
torchvision==0.19.0
imageio[ffmpeg]==2.34.2
transformers==4.43.2
triton==3.0.0; sys_platform == 'linux' and platform_machine == 'x86_64'
txtsplit==1.0.0
uvicorn==0.30.3
yt-dlp==2024.7.16
tensorboard==2.17.0
black
ytmusicapi==1.7.5
cutlet==0.4.0
coqpit==0.0.17
pysbd==0.3.4
trainer
rotary-embedding-torch==0.6.4
num2words==0.5.13
Even so, this seems something related to your environment/installation and not from diffusers.
Torch 2.4 has the "register_fake" so if you have installed torch 2.4 you should have that function.
Also I can run your demo code (simplified) without any problem, I have torch 2.4 and torchvision 0.19.
Try a simple demo without diffusers, in the same environment can you run this code which is the example in the same function?
import torch
from torch import Tensor
# Example 1: an operator without data-dependent output shape
@torch.library.custom_op("mylib::custom_linear", mutates_args=())
def custom_linear(x: Tensor, weight: Tensor, bias: Tensor) -> Tensor:
raise NotImplementedError("Implementation goes here")
@torch.library.register_fake("mylib::custom_linear")
def _(x, weight, bias):
assert x.dim() == 2
assert weight.dim() == 2
assert bias.dim() == 1
assert x.shape[1] == weight.shape[1]
assert weight.shape[0] == bias.shape[0]
assert x.device == weight.device
return (x @ weight.t()) + bias
with torch._subclasses.fake_tensor.FakeTensorMode():
x = torch.randn(2, 3)
w = torch.randn(3, 3)
b = torch.randn(3)
y = torch.ops.mylib.custom_linear(x, w, b)
assert y.shape == (2, 3)
Got it, so it's something with our env. Will close this out, thanks!
Maybe you can try to comment this line
@torch.library.register_fake("torchvision::nms")
in your file/usr/local/lib/python3.11/site-packages/torchvision/_meta_registrations.py
.
This worked for me but my torch version was 2.2.2. I was trying to import sentence-transformers package and in the error trace it showed that [Pytorch 2.4.0 - module 'torch.library' has no attribute 'register_fake']. I did your fix and now it is working.
原因很简单啊,你的torch版本和torchvision版本不适配,可以去看一下官方文档两者适配的版本号即可,一般来说如果你的torch是2.3.1版本的话,那么你的torchvision一般为0.18.1即可
Maybe you can try to comment this line
@torch.library.register_fake("torchvision::nms")
in your file/usr/local/lib/python3.11/site-packages/torchvision/_meta_registrations.py
.
Thank you so much, that worked for me!
Describe the bug
When using diffusers with pytorch 2.4.0, there is an error on import
Reproduction
Install diffusers and then instantiate StableVideoDiffusionXL
Logs
System Info
Copy-and-paste the text below in your GitHub issue and FILL OUT the two last points.
Who can help?
@yiyixuxu