YuxinWenRick/tree-ring-watermark

RuntimeError: "roll_cuda" not implemented for 'ComplexHalf'

Jayamoon59 opened this issue · 6 comments

Hi, Sorry to bother you.
I am very interested in your project, but have some problems when I reproduce,
such as "RuntimeError: "roll_cuda" not implemented for 'ComplexHalf'" ,
I didn't find any useful way to solve it, can you help me?

Looking forward to your reply!

Hi, thanks for your interest!

To help me understand the issue better, could you please provide more context? Specifically, could you share the exact line of code causing the problem or the version of torch or diffusers you are using?

Thank you!

E:\Anaconda\envs\zjy\python.exe F:\zjy\tree-ring-watermark-main\run_tree_ring_watermark.py
Fetching 12 files: 100%|██████████| 12/12 [00:00<?, ?it/s]
Cannot initialize model with low cpu memory usage because accelerate was not found in the environment. Defaulting to low_cpu_mem_usage=False. It is strongly recommended to install accelerate for faster and less memory-intense model loading. You can do so with:

pip install accelerate

.
F:\zjy\tree-ring-watermark-main\optim_utils.py:183: UserWarning: ComplexHalf support is experimental and many operators don't support it yet. (Triggered internally at C:\cb\pytorch_1000000000000\work\aten\src\ATen\EmptyTensor.cpp:32.)
gt_patch = torch.fft.fftshift(torch.fft.fft2(gt_init), dim=(-1, -2))
Traceback (most recent call last):
File "F:\zjy\tree-ring-watermark-main\run_tree_ring_watermark.py", line 220, in
main(args)
File "F:\zjy\tree-ring-watermark-main\run_tree_ring_watermark.py", line 51, in main
gt_patch = get_watermarking_pattern(pipe, args, device)
File "F:\zjy\tree-ring-watermark-main\optim_utils.py", line 183, in get_watermarking_pattern
gt_patch = torch.fft.fftshift(torch.fft.fft2(gt_init), dim=(-1, -2))
RuntimeError: "roll_cuda" not implemented for 'ComplexHalf'

进程已结束,退出代码1

Thank you for your reply.

The problem seems to be that ComplexHalf types are not supported, but I can't find a solution. Do I need to upgrade to the torch version? My current torch version is 1.12.1.
Hope to get your help.

Hello, it seems the issue might be related to the torch.fft module. I'm currently using PyTorch version 1.13.0. While I'm not certain of the exact differences in the fft implementation between versions, updating your PyTorch to version 1.13.0 may resolve the problem. Could you please try upgrading and let me know if it helps?

Thank you very much, PyTorch version 1.13.0 solves the problem perfectly.

In addition, I would like to ask you a more technical question. In the future work of the article, you mentioned that "the accuracy of reverse diffusion can be improved". I would like to try if there is any clear instruction on which .py file to modify.

Hi, I'm glad to hear that the issue has been resolved.

Yeah, right now, our implementation is using DDIM, and the inversion is not perfect as we mentioned in the paper. Therefore, we expect the inverted latent could be more accurate with better (deterministic) sampling methods. You can modify the scheduler when generating the image here, and for inversion, you may want to modify this part.

Hi @Jayamoon59 , I just found this new paper that came up with a more accurate inversion process. In section 5.2., they applied their new inversion process to tree-ring and got a better result. Hope this is interesting to you.

Meanwhile, I'm gonna close this issue. Let me know if you have further questions!