Open danielthompson opened 2 years ago
Same here on Windows, fresh environment
Same problem on Linux Mint. It looks like problem is located in pretrained model types, CLIP, transformers and/or PyTorch. Pretrained models was saved at float16 (see f16
at download script) precision aka "Half" data type and it breaks some PyTorch methods in CPU. I had ran this code but I had put a lot of .to(dtype=torch.float32)
in different places (such as CLIP/clip/model.py, torch/nn/functional.py, torch/nn/activation.py, torch/nn/linear.py, torch/nn/conv.py). It is very ugly, unpowerful and terrible solution, please, don't be like me... I will wait for better way...
i am having the same problem, it worked on some crapy intel cpu but not on my amd one
any options for a workaround? my RAM is substantially larger than my GPU memory lol
i am having the same problem manjaro i7 3770
Hi all i have a simple "fix" for those who have this error if they want to use cpu.
In ~/VQGAN-CLIP/CLIP/clip/model.py
just comment out the function that converts to fp16
so change the function in line 371 to
def convert_weights(model: nn.Module):
"""Convert applicable model parameters to fp16"""
def _convert_weights_to_fp16(l):
"""
if isinstance(l, (nn.Conv1d, nn.Conv2d, nn.Linear)):
l.weight.data = l.weight.data.half()
if l.bias is not None:
l.bias.data = l.bias.data.half()
if isinstance(l, nn.MultiheadAttention):
for attr in [*[f"{s}_proj_weight" for s in ["in", "q", "k", "v"]], "in_proj_bias", "bias_k", "bias_v"]:
tensor = getattr(l, attr)
if tensor is not None:
tensor.data = tensor.data.half()
for name in ["text_projection", "proj"]:
if hasattr(l, name):
attr = getattr(l, name)
if attr is not None:
attr.data = attr.data.half()
"""
pass
model.apply(_convert_weights_to_fp16)
then it works. (or simply delete it if you dont plan on using gpu mode later again)
@dehaenw Thank you for your answer, I tried it out, the code is running but produced images are all kind of white noises, did you experience similar behaviour or everything was working fine?
@FlavioLeccese92 It works for me, however it is very slow (~10x slower than an old gpu in my task), otherwise i did not notice any unusual noise except the initialized image before it converges to target
@dehaenw by unusual you mean something like this?
Sorry to bother you and thank you again for your support
@FlavioLeccese92 no, not like your example image, which looks like the colors are somehow clipped or restricted to rgb values of 0 or 255 only per color. my initialized images just look like this:
maybe some imporoper type conversion at some point?
Bug
I get
RuntimeError: "softmax_lastdim_kernel_impl" not implemented for 'Half'
when running this against my CPU.To reproduce
Gives
Expected behavior
No error; generate an output image.
Additional notes
-cd cpu
parameterEnvironment