Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: "clamp_scalar_cpu" not implemented for 'Half' #62

Open
Tany-g opened this issue Dec 27, 2023 · 1 comment
Open

RuntimeError: "clamp_scalar_cpu" not implemented for 'Half' #62

Tany-g opened this issue Dec 27, 2023 · 1 comment

Comments

@Tany-g
Copy link

Tany-g commented Dec 27, 2023

This error occurred when I tried to run it.
/home/ubuntu/anaconda3/envs/streamdiffusion/lib/python3.10/site-packages/diffusers/image_processor.py:339: FutureWarning: Passing imageas torch tensor with value range in [-1,1] is deprecated. The expected value range for image tensor is [0,1] when passing as pytorch tensor or numpy Array. You passedimage with value range [-0.050994873046875,1.0] warnings.warn( Exception in thread Thread-1 (_receive_images): Traceback (most recent call last): File "/home/ubuntu/anaconda3/envs/streamdiffusion/lib/python3.10/threading.py", line 1016, in _bootstrap_inner self.run() File "/home/ubuntu/anaconda3/envs/streamdiffusion/lib/python3.10/threading.py", line 953, in run self._target(*self._args, **self._kwargs) File "/home/ubuntu/GITHUG/StreamDiffusion/examples/screen/../../utils/viewer.py", line 54, in _receive_images postprocess_image(queue.get(block=False), output_type="pil")[0], File "/home/ubuntu/anaconda3/envs/streamdiffusion/lib/python3.10/site-packages/streamdiffusion/image_utils.py", line 60, in postprocess_image [ File "/home/ubuntu/anaconda3/envs/streamdiffusion/lib/python3.10/site-packages/streamdiffusion/image_utils.py", line 61, in <listcomp> denormalize(image[i]) if do_denormalize[i] else image[i] File "/home/ubuntu/anaconda3/envs/streamdiffusion/lib/python3.10/site-packages/streamdiffusion/image_utils.py", line 13, in denormalize return (images / 2 + 0.5).clamp(0, 1) RuntimeError: "clamp_scalar_cpu" not implemented for 'Half'

Env:ubuntu1804
GPU:RTX3090*2
cuda:11.4

@cvv-student
Copy link

I also encountered this problem. The issue is that the CPU model does not support FP16 calculations. I switched it to FP32 calculations, and edited the error message in 'image_utils.py' in the function 'denormalize'. I added the following code:
'if images.dtype==torch.float16 and images.device.type=="cpu": images = images.float()
and that worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants